gql-request-node
v1.1.5
Published
Downloads
8
Maintainers
Readme
gql-request-node
Consume api de graphql desde node.js
ejemplo
const { client } = require('gql-request-node');
const query = `
{
message
}
`;
client("localhost:3000/graphql")
.then(res => console.log(res))
.catch(err => console.log(err));
Salida
{ data:
{ message: "Hola mundo" }
}
pasando variables a la query
const query = `
query saludo($message: String!) {
saludo(message: $message)
}
`;
const variables = { message: "Hans" };
client('localhost:3000/graphql', { variables })
.then(res => console.log(res))
.catch(err => console.log(err));
Salida
{
data: {
message: "Hola, Hans"
}
}