Guest User

Untitled

a guest
Jan 14th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. 'use strict'
  2.  
  3. const { makeExecutableSchema } = require('graphql-tools')
  4. const resolvers = require('./resolvers')
  5.  
  6. // Define our schema using the GraphQL schema language
  7. const typeDefs = `
  8. type User {
  9. id: Int!
  10. username: String!
  11. email: String!
  12. posts: [Post]
  13. }
  14. type Post {
  15. id: Int!
  16. title: String!
  17. slug: String!
  18. content: String!
  19. user: User!
  20. }
  21. type Query {
  22. allUsers: [User]
  23. fetchUser(id: Int!): User
  24. allPosts: [Post]
  25. fetchPost(id: Int!): Post
  26. }
  27. type Mutation {
  28. login (email: String!, password: String!): String
  29. createUser(username: String!, email: String!, password: String!): User
  30. addPost(title: String!, content: String!): Post
  31. }
  32. `
  33.  
  34. module.exports = makeExecutableSchema({ typeDefs, resolvers })
Add Comment
Please, Sign In to add comment