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 { Binding } = require('graphql-binding') | |
const { makeExecutableSchema } = require('graphql-tools') | |
class HelloBinding extends Binding { | |
constructor() { | |
const typeDefs = ` | |
type Query { | |
hello(name: String): 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
const postServiceBinding = new RemoteBinding({ | |
typeDefsPath: '../schemas/post-service.graphql', | |
endpoint: 'https://post-service-nyvvyjtbyt.now.sh', | |
}) | |
const userServiceBinding = new RemoteBinding({ | |
typeDefsPath: '../schemas/user-service.graphql', | |
endpoint: 'https://user-service-lvzqpqmeqb.now.sh/', | |
}) | |
const server = new GraphQLServer({ |
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 fs = require('fs') | |
const path = require('path') | |
const fetch = require('node-fetch') | |
const { Binding } = require('graphql-binding') | |
const { HttpLink } = require('apollo-link-http') | |
const { makeRemoteExecutableSchema } = require('graphql-tools') | |
class RemoteBinding extends Binding { | |
constructor({ typeDefsPath, endpoint }) { | |
const link = new HttpLink({ uri: endpoint, fetch }) |
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
type Query { | |
user(id: ID!): User | |
users: [User!]! | |
} | |
type Mutation { | |
createUser(name: String!): User! | |
updateUser(id: ID!, name: String!): User | |
deleteUser(id: ID!): User | |
} |
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 fs = require('fs') | |
const path = require('path') | |
const fetch = require('node-fetch') | |
const { Binding } = require('graphql-binding') | |
const { HttpLink } = require('apollo-link-http') | |
const { makeRemoteExecutableSchema } = require('graphql-tools') | |
const link = new HttpLink({ uri: 'https://post-service-nyvvyjtbyt.now.sh', fetch }) | |
const typeDefs = fs.readFileSync( | |
path.join(__dirname, '../schemas/post-service.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
type Query { | |
posts(searchString: String): [Post!]! | |
} | |
type Mutation { | |
createDraft(title: String!, content: String!): Post | |
publish(id: ID!): Post | |
deletePost(id: ID!): Post | |
} |
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
type Query { | |
posts: [Post!]! | |
post(id: ID!): Post | |
description: String! | |
} | |
type Mutation { | |
createPost(title: String!, content: String!, published: Boolean): Post! | |
updatePost(id: ID!, title: String, content: String, published: Boolean): Post | |
deletePost(id: ID!): Post |
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
type Query { | |
posts: [Post!]! | |
post(id: ID!): Post | |
} | |
type Mutation { | |
createPost(title: String!, content: String!, published: Boolean): Post! | |
updatePost(id: ID!, title: String, content: String, published: Boolean): Post | |
deletePost(id: ID!): Post | |
} |
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 userBinding = require('graphql-binding-users') | |
const generateName = require('sillyname') | |
const resolvers = { | |
Query: { | |
user: async (parent, args, context, info) => { | |
const users = await userBinding.query.users({}, info) | |
return users.find(user => user.id === args.id) | |
}, | |
}, |
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
type Query { | |
user(id: ID!): User | |
} | |
type Mutation { | |
createUserWithRandomName: User! | |
} |