0

Im trying out react starter kit and have some confusion with GraphQL and parameters. I just don't know how to pass parameters to the query:

fetch('/graphql', {
            method: 'post',
            headers: {
                Accept: 'application/json',
                'Content-Type': 'application/json',
            },
            body: JSON.stringify({
                query: '{searchquery{title}}',
            })
        });

It's searchquery that should have a string argument somehow.

freakshow
  • 461
  • 8
  • 16
  • Since you're using React and GraphQL, you may want to give [Relay](https://github.com/facebook/relay) a shot. Relay automatically manages necessary queries and caching of the results. You just need to declare the data requirements, without having to worry about how to construct the query. – Ahmad Ferdous Apr 10 '16 at 03:38

1 Answers1

2

To answer my own question.

fetch('/graphql', {
        method: 'post',
        headers: {
            Accept: 'application/json',
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({
            query: '{searchquery(query:"test"){title}}',
        })
    });
freakshow
  • 461
  • 8
  • 16