Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Taller: Datos en tiempo real con GraphQL

105 views

Published on

En este taller práctico construiremos un backend sencillo de GraphQL utilizando GraphQL Yoga, un servidor open source para GraphQL.

Nota: Los participantes requieren traer una computadora con cierto software preinstalado y estudiar previamente cierta teoría básica sobre GraphQL — https://github.com/Ikana/dataday-gql
Por Rodrigo Quezada

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Taller: Datos en tiempo real con GraphQL

  1. 1. Real time data with GraphQL Rodrigo Quezada @rodikana
  2. 2. Lo que vamos a hacer hoy
  3. 3. Graph Query Language
  4. 4. Query query { user(id: "abc") { id name } }
  5. 5. type User { id: ID! name: String } Schema type Query { user(id: ID!): User }
  6. 6. Schema const UserType = new GraphQLObjectType({ name: 'User', fields: { id: { type: GraphQLID }, name: { type: GraphQLString } } }) const schema = new GraphQLSchema({ query: new GraphQLObjectType({ name: 'Query', fields: { user: { type: UserType, args: { id: { type: GraphQLID } } } } }) })
  7. 7. Schema const schema = new GraphQLSchema({ query: new GraphQLObjectType({ name: 'Query', fields: { user: { type: UserType, args: { id: { type: GraphQLID } }, resolve: (root, args, context, info) => { const { id } = args // the `id` argument for this field is declared above return fetchUserById(id) // hit the database } } } }) })
  8. 8. Schema const UserType = new GraphQLObjectType({ name: 'User', fields: { id: { type: GraphQLID, resolve: (root, args, context, info) => { return root.id } }, name: { type: GraphQLString, resolve: (root, args, context, info) => { return root.name } } } })
  9. 9. query { user(id: "abc") { name article(title: "GraphQL is great") { comments { text writtenBy { name } } } } }
  10. 10. https://www.youtube.com/ watch?v=OQTnXNCDywA DataLoader
  11. 11. const { makeExecutableSchema } = require('graphql-tools') const typeDefs = ` type Query { user(id: ID!): User } type User { id: ID! name: String }` const resolvers = { Query: { user: (root, args, context, info) => { return fetchUserById(args.id) } }, } const schema = makeExecutableSchema({ typeDefs, resolvers })
  12. 12. GraphQL Yoga
  13. 13. graphql-subscriptions
  14. 14. front-end
  15. 15. Preguntas
  16. 16. Gracias!
  17. 17. chat.javascriptmx.com

×