facebook / relay

Relay is a JavaScript framework for building data-driven React applications.
https://relay.dev
MIT License
18.41k stars 1.83k forks source link

Expected a value matching type 'JSON', but got an object value... #2494

Open ChiuMungZitAlexander opened 6 years ago

ChiuMungZitAlexander commented 6 years ago

Dear friends,

I am employing graphql and relay in a new project.

As you can see, the backend developer defined the schema as below

type Viewer {
  allAccounts(query: JSON)
}

Meanwhile, in the container, I created the query as below

graphql`
 accountTableQuery($name: String) {
    Viewer {
      allAccounts(query: {name: $name}
    }
  }
`

Then, after I ran relay-compiler, it occurs the error that "Expected a value matching type 'JSON', but got an object value".

I guess it is about the part of query:{name: $name}. Because the schema restricts the query as type of JSON. But maybe in graphql compiling, the process considers it as an object.

Could you please help me solve this problem?

jgcmarins commented 6 years ago

check this example: https://github.com/entria/graphql-dataloader-boilerplate see if it helps

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.