Skip to content

Instantly share code, notes, and snippets.

@thawkin3
Last active January 30, 2021 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thawkin3/3186d8d87eec04b3bfc2d1c1a5df8846 to your computer and use it in GitHub Desktop.
Save thawkin3/3186d8d87eec04b3bfc2d1c1a5df8846 to your computer and use it in GitHub Desktop.
Type definitions for Jokes and Ratings and how to query them
const { gql } = require('apollo-server-express')
const typeDefs = gql`
type Joke {
id: Int!
content: String!
ratings: [Rating]
}
type Rating {
id: Int!
jokeId: Int!
score: Int!
}
type Query {
joke(id: Int!): Joke
jokes: [Joke]
rating(id: Int!): Rating
ratings: [Rating]
}
type Mutation {
rating(jokeId: Int!, score: Int!): Rating
}
`
module.exports = typeDefs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment