Skip to content

Instantly share code, notes, and snippets.

@AgustinCastella
Last active April 26, 2021 20:30
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 AgustinCastella/f5d9e446a0ad30670df09bb82da08167 to your computer and use it in GitHub Desktop.
Save AgustinCastella/f5d9e446a0ad30670df09bb82da08167 to your computer and use it in GitHub Desktop.
Define your graphql schema
const express = require('express');
const { ApolloServer, gql } = require('apollo-server-express');
// A schema is a collection of type definitions (hence "typeDefs")
// that together define the "shape" of queries that are executed against
// your data.
const typeDefs = gql`
# Comments in GraphQL strings (such as this one) start with the hash (#) symbol.
# This "Book" type defines the queryable fields for every book in our data source.
type Book {
title: String
author: String
}
# The "Query" type is special: it lists all of the available queries that
# clients can execute, along with the return type for each. In this
# case, the "books" query returns an array of zero or more Books (defined above).
type Query {
books: [Book]
}
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment