Skip to content

Instantly share code, notes, and snippets.

@bs1180
Created September 15, 2016 18:56
Show Gist options
  • Save bs1180/a5b64b0f04d208882d9793338b2f6514 to your computer and use it in GitHub Desktop.
Save bs1180/a5b64b0f04d208882d9793338b2f6514 to your computer and use it in GitHub Desktop.
Apollo server schema definitions

By

user.js

const type = `
  type User {
    id: Int!
    email: String
    courses: [Course]
  }
`

const resolver = {
  courses: () => fetchCourses()
}

course.js

const type = `
  type Course {
    id: Int!
    name: String
  }
`

schema.js

import * as User from './User'
import * as Course from './Course

const schema = `
  ${User.type}
  ${Course.type}
`

const Resolvers = {
  RootQuery: ...
  User.resolver
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment