facebook / facebook/relay

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

Open
#2,494 2 comments 0 reactions 0 assignees View on GitHub
wontfix
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

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?

Contributor guide

Open the contributing guide

Research direction

Start with the relay-compiler error and compare the JSON argument in the schema with the object literal in the query shown in the issue. Reproduce the mismatch with these snippets and determine the expected compiler behavior; done means the cause and required change to the query or schema are established.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, javascript
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.