Query don't work [NodeJS]


#1

Hi everyone,
I tried to do some requests to my database :

With the code :

.use('/graphql', graphqlHTTP(( req ) => {
    let sess = req.session;
    sess.ctx = {};

    return {
        schema    : PublicSchema,
        pretty    : true,
        graphiql  : true,
        rootValue : {
          schema : 'public'
        },
        context   : sess.ctx
      };
    })
  )

And as you can see that worked.
But when I try to do that with NodeJS, the request don’t work :

.get('/zob', function(req, res){
    let sess = req.session;
    sess.ctx = {};
    var { graphql } = require('graphql');
    var query = 'mutation{getToken(email:"###", password:"##"){token}}';
    graphql(PublicSchema, query, sess.ctx).then((response) => {
      console.log("hey");
      console.log(response);
    });
  })

(I put the real email and password in my code)
And the console respond :
"{ data: { getToken: { token: null } }" with error : "TypeError: Cannot read property ‘token’ of undefined"
GetToken function return null…

So, i did the same thing on GraphiQL and nodeJS but with NodeJS the query don’t work. Why ???

Can you help me ?
Thanks!


#2

I am going to close this thread because I’ve determined that it is off-topic.

Please use this forum to discuss the GitHub Platform Early Access programs.

If you have feedback, questions, or suggestions about GitHub features that are not covered by the GitHub Platform Early Access programs, write in to GitHub Support.


#3