PhotoShare is the main back-end exercise for GraphQL Workshop. In this exercise, students build a GraphQL API for a small photo sharing application.
scalar DateTime
type Photo {
id: ID!
name: String!
url: String!
description: String
category: PhotoCategory!
postedBy: User!
created: DateTime!
}
resolvers.js
const { GraphQLScalarType } = require('graphql')
__resolvers.js__
...
module.exports = {
...
DateTime: new GraphQLScalarType({
name: 'DateTime',
description: 'A valid date time value.',
parseValue: value => new Date(value),
serialize: value => new Date(value).toISOString(),
parseLiteral: ast => ast.value
})
}
- Drop the photos collection
- Delete the photos from the assets folder
- navigate to http://localhost:4000/img/photos
query {
allPhotos {
id
url
created
}
}
- Initial Project Folder
- Apollo Server 2.0
- Counting the Photos
- Posting a Photo
- Handling Photo Categories
- Using an Input Type
- Listing All Photos
- Querying a Single Photo
- Challenge: Adding the User Type
- Connecting Photos to Users
- Connecting Users to Photos
- Adding currentUser to context
- Add environment and refactor
- Configuring a Database
- Configure an express server
- Configure Github OAuth
- Add
githubLogin
mutation - Add fake users to
githubLogin
mutation - Identify the
currentUser
- Post new Photos to the Database
- Adding Subscription Support
- Uploading File with postPhoto
- Adding custom scalar for
DateTime