Skip to content

Instantly share code, notes, and snippets.

@daniloab
Created June 12, 2019 18:11
Show Gist options
  • Save daniloab/82fd332ca8b728663fdb847aa33719ac to your computer and use it in GitHub Desktop.
Save daniloab/82fd332ca8b728663fdb847aa33719ac to your computer and use it in GitHub Desktop.
Simple example app.js
const graphqlSettingsPerReq = async req => {
const { user } = await getUser(req.header.authorization);
return {
graphiql: process.env.NODE_ENV !== 'production',
schema,
context: {
user,
req,
dataloaders,
},
formatError: error => {
console.log(error.message);
console.log(error.locations);
console.log(error.stack);
return {
message: error.message,
locations: error.locations,
stack: error.stack,
};
},
}
}
// Iniciamos um no server GraphQL
const graphqlServer = GraphQLHTTP(graphqlSettingsPerReq)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment