1

I want to send lot of parameters to my query, and i don't want to define it. So i try to pass JSON parameter but i haven't lot of success with it.

I use the https://github.com/taion/graphql-type-json module.

This is my query definition :

usersByParams(params: JSON): [User]

My resolver is :

usersByParams: (_, { params }) => { console.log('PARAMS', params); return users; }

And my query is :

query getUsersByParams {
    usersByParams(params: {test: 'this not work'}) {
        id 
        firstName
        lastName 
        email
        password
    }
}

I my resolvers i always fot "FALSE" value for params. I you have any tips for passing json Thank's

1 Answer 1

1

Add this in your resolver

import GraphQLJSON from 'graphql-type-json';

JSON: {

  __serialize(value) {
    return GraphQLJSON.parseValue(value);
  }
  __parseLiteral(ast) {
    return GraphQLJSON.parseValue(value);
  }
}

I think this may solve your problem

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.