Skip to content

Commit

Permalink
explain JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
spawnia committed Mar 14, 2024
1 parent 577a13a commit 3674648
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ A [RFC 5321](https://tools.ietf.org/html/rfc5321) compliant email.

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

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

```graphql
type Query {
Expand All @@ -65,6 +65,26 @@ type Query {
}
```

```json
// Wrong, the variable value is a JSON object
{
"query": "query ($bar: JSON!) { foo(bar: $bar) }",
"variables": {
"bar": {
"baz": 2
}
}
}

// Correct, the variable value is a JSON string representing an object
{
"query": "query ($bar: JSON!) { foo(bar: $bar) }",
"variables": {
"bar": "{ \"bar\": 2 }"
}
}
```

JSON responses will contain nested JSON strings.

```json
Expand Down

0 comments on commit 3674648

Please sign in to comment.