Skip to content

Commit 3674648

Browse files
committed
explain JSON
1 parent 577a13a commit 3674648

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ A [RFC 5321](https://tools.ietf.org/html/rfc5321) compliant email.
4747

4848
Arbitrary data encoded in JavaScript Object Notation. See https://www.json.org.
4949

50-
This expects a string in JSON format, not a GraphQL literal.
50+
This expects a string in JSON format, not an arbitrary JSON value or GraphQL literal.
5151

5252
```graphql
5353
type Query {
@@ -65,6 +65,26 @@ type Query {
6565
}
6666
```
6767

68+
```json
69+
// Wrong, the variable value is a JSON object
70+
{
71+
"query": "query ($bar: JSON!) { foo(bar: $bar) }",
72+
"variables": {
73+
"bar": {
74+
"baz": 2
75+
}
76+
}
77+
}
78+
79+
// Correct, the variable value is a JSON string representing an object
80+
{
81+
"query": "query ($bar: JSON!) { foo(bar: $bar) }",
82+
"variables": {
83+
"bar": "{ \"bar\": 2 }"
84+
}
85+
}
86+
```
87+
6888
JSON responses will contain nested JSON strings.
6989

7090
```json

0 commit comments

Comments
 (0)