1
0

test.js 757 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { GraphQLSchema, GraphQLObjectType, GraphQLString } from "graphql";
  2. /**
  3. * Construct a GraphQL schema and define the necessary resolvers.
  4. *
  5. * type Query {
  6. * hello: String
  7. * }
  8. * type Subscription {
  9. * greetings: String
  10. * }
  11. */
  12. // eslint-disable-next-line
  13. export const schema = new GraphQLSchema({
  14. query: new GraphQLObjectType({
  15. name: "Query",
  16. fields: {
  17. hello: {
  18. type: GraphQLString,
  19. resolve: () => "world"
  20. }
  21. }
  22. }),
  23. subscription: new GraphQLObjectType({
  24. name: "Subscription",
  25. fields: {
  26. greetings: {
  27. type: GraphQLString,
  28. async *subscribe() {
  29. // eslint-disable-next-line
  30. for (const hi of ["Hi", "Bonjour", "Hola", "Ciao", "Zdravo"]) {
  31. yield { greetings: hi };
  32. }
  33. }
  34. }
  35. }
  36. })
  37. });