Last active
June 18, 2017 16:31
-
-
Save ivanbtrujillo/f6f573b1feb9eb67235bafb7afb9e2ff to your computer and use it in GitHub Desktop.
GraphQL. 03 — Schemas y GraphiQL - 02
This file contains hidden or 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
// Importamos la librería GraphQl | |
const graphql = require('graphql'); | |
/* | |
Usamos el deestructuring de Javascript Es6 para extraer el objeto GraphQLObjectType del objeto graphql | |
(el cual es la librería) para poder utilizarlo fuera. | |
*/ | |
const { | |
GraphQLObjectType, | |
GraphQLString | |
} = graphql; | |
const UserType = new GraphQLObjectType({ | |
// El nombre de la entidad (imagina que es una tabla SQL) | |
name: 'User', | |
// Los distintos campos que va a tener | |
fields: { | |
id: { type: GraphQLString }, | |
firstName: { type: GraphQLString }, | |
lastName: { type: GraphQLString }, | |
country: { type: GraphQLString } | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment