Skip to content

Instantly share code, notes, and snippets.

View timjbray's full-sized avatar

Tim Bray timjbray

View GitHub Profile
// define the graphql query
const UserQueryDefs = gql`
extend type Query {
user(id: ID): User
}
`;
// graphql resolver
async user(_, args, context): Promise<any> {
// return the requested user
const server = new ApolloServer({
typeDefs,
resolvers,
context: graphQLContext
});
const graphQLContext = (context) => {
const { req, res } = context;
// use a express middleware to auth user
const server = new ApolloServer({
typeDefs,
resolvers,
context: graphQLContext,
formatError: (error: any) => {
// filter whatever errors your don't want to log
logger.error(`[GraphQL.error] ${error.message}`, error);
return error;
},
formatResponse: (response: any) => {
### Keybase proof
I hereby claim:
* I am timjbray on github.
* I am timjbray (https://keybase.io/timjbray) on keybase.
* I have a public key ASCcehdRyHuWsfY3BCZLtORi2gsDSs9O8S48Ffbc_ehnPAo
To claim this, I am signing this object: