Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jthegedus/2d6eebab750fcf3e95d992d76e205c93 to your computer and use it in GitHub Desktop.
Save jthegedus/2d6eebab750fcf3e95d992d76e205c93 to your computer and use it in GitHub Desktop.
Cloud Functions for Firebase - GraphQL Server - /functionsES6/graphql/data/schema.js
import { makeExecutableSchema } from "graphql-tools"
import resolvers from "./resolvers"
const schema = `
type Author {
id: Int! # the ! means that every author object _must_ have an id
firstName: String
lastName: String
posts: [Post] # the list of Posts by this author
}
type Post {
id: Int!
title: String
author: Author
votes: Int
}
# the schema allows the following query:
type Query {
posts: [Post]
author(id: Int!): Author
}
# this schema allows the following mutation:
type Mutation {
upvotePost (
postId: Int!
): Post
}
`
export default makeExecutableSchema({
typeDefs: schema,
resolvers
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment