Guest User

Untitled

a guest
Jan 20th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. const { makeExecutableSchema } = require('graphql-tools')
  2. const { Binding } = require('graphql-binding')
  3.  
  4. const users = [
  5. {
  6. name: 'Alice',
  7. },
  8. {
  9. name: 'Bob',
  10. },
  11. ]
  12.  
  13. const typeDefs = `
  14. type Query {
  15. findUser(name: String!): User
  16. }
  17.  
  18. type User {
  19. name: String!
  20. }
  21. `
  22.  
  23. const resolvers = {
  24. Query: {
  25. findUser: (parent, { name }) => users.find(u => u.name === name),
  26. },
  27. }
  28.  
  29. const schema = makeExecutableSchema({ typeDefs, resolvers })
Add Comment
Please, Sign In to add comment