1

I have a simple implementation of graphQl on my api, but can't seem to get any other arguments than args from the resolvers. The code is pretty simple, so it shouldn't cause any issue :

const bindGraphqlModule = (app) => {
  app.use(
    "/graphql",
    graphqlHTTP(() => {
      return {
        schema: graphQLSchema,
        rootValue: resolvers,
        context: {
          test: "hi ?"
        },
        graphiql: process.env.NODE_ENV !== "production",
      };
    })
  );
};

and then my resolver :

const resolver = async (args, context, test) => {
  console.log(context, test);
  const { email, password } = args;
  ...

Args are accessible normally, but context and test are both undefined. Any clue ?

Fed
  • 11
  • 2

1 Answers1

0

My bad, i actually englobed resolvers in a function to handle error, and didn't pass the context through totally. Solved

Fed
  • 11
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 17 '21 at 16:31