Graphql-js: Getting undefined in contextValue

Created on 10 Jun 2020  路  2Comments  路  Source: graphql/graphql-js

Reporting issues with GraphQL.js

Getting error while using Graphql contextValue
I have followd https://graphql.org/code/#javascript aand tried below function to run graphql through GraphQL.js
graphql(schema, query , resolvers, {db})

Parameter details =>
schema contains schema info through buildSchema
added query through graphiql
added resolvers functions in object {}
as a part of context i want to share my db instance which i can use in every resolver function.

however I am not getting undefined inside third parameter of my resolver function when I run query from graphiql.

Also documentation does not provide clear instruction on how to use contextValue parameter in graphql function of graphql-js module.

question

Most helpful comment

@beingminimal If you want help with an issue it is more effective to spend some time and create minimal code sample.
Also, it is rude to ping people after only 5min of waiting.

If you specify your resolver as a method of root object you will get your context as a second parameter, not the third as you would get if registered it as resolve function on a field.

All 2 comments

Can you please help with this issue?
@solon , @cito, @wtrocki @IvanGoncharov

@beingminimal If you want help with an issue it is more effective to spend some time and create minimal code sample.
Also, it is rude to ping people after only 5min of waiting.

If you specify your resolver as a method of root object you will get your context as a second parameter, not the third as you would get if registered it as resolve function on a field.

Was this page helpful?
0 / 5 - 0 ratings