This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import express from 'express'; | |
import {graphiqlExpress, graphqlExpress } from 'apollo-server-express'; | |
import bodyParser from 'body-parser'; | |
import mongoose from 'mongoose'; | |
import schema from './schema'; | |
const server = express(); | |
server.use('/graphiql', graphiqlExpress({ | |
endpointURL: "/graphql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const resolvers = { | |
Query: { | |
authors: () => { | |
return authors | |
}, | |
author: (root, args) => { | |
const age = args.age; | |
return authors.find(author => author.age === age); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const resolvers = { | |
Query: { | |
authors: () => { | |
return authors | |
}, | |
author: (root, args) => { | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const typeDefs = ` | |
type Author { | |
age: Int | |
name: String, | |
Books: [String] | |
} | |
type Query { | |
authors: [Author] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const authors = [ | |
{ | |
name: 'JK Rowling', | |
age: 50, | |
Books: ["Harry Potter and the Goblet of Fire", "Harry Potter and the Prisoner of Azkaban"] | |
}, | |
{ | |
name: 'George RR Marting', | |
age: 70, | |
Books: ["GOT - Song of Ice and Fire", "GOT - A Dance with Dragons"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const authors = [ | |
{ | |
name: 'JK Rowling', | |
age: 50 | |
books: ["Harry Potter and the Goblet of Fire", "Harry Potter and the Prisoner of Azkaban"] | |
}, | |
{ | |
name: 'George RR Marting', | |
age: 70, | |
books: ["GOT - Song of Ice and Fire", "GOT - A Dance with Dragons"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import express from 'express'; | |
import {graphiqlExpress, graphqlExpress } from 'apollo-server-express'; | |
import bodyParser from 'body-parser'; | |
import schema from './schema'; | |
const server = express(); | |
server.use('/graphiql', graphiqlExpress({ | |
endpointURL: "/graphql" | |
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {makeExecutableSchema, addMockFunctionsToSchema} from 'graphql-tools'; | |
const typeDefs = ` | |
type Author { | |
age: Int | |
name: String, | |
Books: [String] | |
} | |
type Query { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {makeExecutableSchema, addMockFunctionsToSchema} from 'graphql-tools'; | |
const typeDefs = ` | |
type Author { | |
age: Int | |
name: String, | |
Books: [String] | |
} | |
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {makeExecutableSchema} from 'graphql-tools'; | |
const typeDefs = ` | |
type Author { | |
age: Int | |
name: String, | |
Books: [String] | |
} | |
`; |