me sale error node index.js (node:6460) UnhandledPromiseRejectionWarning: Error: Expected undefined to be a GraphQL schema. at assertSche...

Pregunta de la clase:
Schema y types
wveimar mamian

wveimar mamian

Pregunta
studenthace 4 años

me sale error

node index.js

(node:6460) UnhandledPromiseRejectionWarning: Error: Expected undefined to be a GraphQL schema.

at assertSchema (/home/wveimar/Documentos/graphql/node_modules/graphql/type/schema.js:37:11)

at validateSchema (/home/wveimar/Documentos/graphql/node_modules/graphql/type/validate.js:34:28)

at graphqlImpl (/home/wveimar/Documentos/graphql/node_modules/graphql/graphql.js:60:64)

at /home/wveimar/Documentos/graphql/node_modules/graphql/graphql.js:23:43

at new Promise (<anonymous>)

at graphql (/home/wveimar/Documentos/graphql/node_modules/graphql/graphql.js:23:10)

at Object.<anonymous> (/home/wveimar/Documentos/graphql/index.js:13:1)

at Module._compile (internal/modules/cjs/loader.js:1085:14)

at Object.Module._extensions…js (internal/modules/cjs/loader.js:1114:10)

at Module.load (internal/modules/cjs/loader.js:950:32)

(Use

node --trace-warnings ...
to show where the warning was created)

(node:6460) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag

--unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

(node:6460) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

1 respuestas
para escribir tu comentario
    Diego Fernando Caviedes Camaho

    Diego Fernando Caviedes Camaho

    studenthace 3 años

    Esto sucede porque debemos pasarselo como objecto

    'use strict' const { graphql, buildSchema } = require('graphql') // definiendo el esquema const schema = buildSchema(` type Query { hello: String } `) graphql({ schema: schema, source: '{ hello }'}) .then((data) => { console.log(data) })
Curso de GraphQL [Empieza Gratis]

Curso de GraphQL [Empieza Gratis]

Maneja tus datos de manera sencilla en el backend y en el frontend con GraphQL. Implementa esta solución creada por Facebook y aprovecha su versatilidad en la consulta y manipulación de APIs. Desarrolla tus proyectos de forma increíblemente fácil con Platzi.

Curso de GraphQL [Empieza Gratis]
Curso de GraphQL [Empieza Gratis]

Curso de GraphQL [Empieza Gratis]

Maneja tus datos de manera sencilla en el backend y en el frontend con GraphQL. Implementa esta solución creada por Facebook y aprovecha su versatilidad en la consulta y manipulación de APIs. Desarrolla tus proyectos de forma increíblemente fácil con Platzi.