You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When making an HTTP POST request with extensions field set to null Apollo Router returns INVALID_GRAPHQL_REQUEST error:
$ curl -H 'content-type: application/json' -d '{"query":"{__typename}","extensions":null}' http://127.0.0.1:4000/
{"errors":[{"message":"Invalid GraphQL request","extensions":{"details":"failed to deserialize the request body into JSON: invalid type: null, expected a map at line 1 column 41","code":"INVALID_GRAPHQL_REQUEST"}}]}
Note: Specifying null for optional request parameters is equivalent to not specifying them at all.
To Reproduce
When specifying extensions field in POST request as null, the following error is produced:
$ curl -H 'content-type: application/json' -d '{"query":"{__typename}","extensions":null}' http://127.0.0.1:4000/
{"errors":[{"message":"Invalid GraphQL request","extensions":{"details":"failed to deserialize the request body into JSON: invalid type: null, expected a map at line 1 column 41","code":"INVALID_GRAPHQL_REQUEST"}}]}
However, omitting extensions field works as expected:
Expected behavior
Apollo Router should process POST requests with extensions field set to null as if there was no extensions field specified.
Output
Please, see To reproduce section.
Desktop (please complete the following information):
OS: Ubuntu
Version: 18.04
Additional context
Setting null_is_default = truehere seems to fix the issue - requests with extensions=null start working as expected, but this was not thoroughly tested.
$ git diff
diff --git a/apollo-router/src/request.rs b/apollo-router/src/request.rs
index cbd3c3d7..dfe91bc7 100644
--- a/apollo-router/src/request.rs
+++ b/apollo-router/src/request.rs
@@ -281,7 +281,7 @@ impl<'data, 'de> DeserializeSeed<'de> for RequestFromBytesSeed<'data> {
}
let seed = serde_json_bytes::value::BytesSeed::new(self.0);
let value = map.next_value_seed(seed)?;
- let null_is_default = false;
+ let null_is_default = true;
extensions = Some(as_object(value, null_is_default)?);
}
Field::Other => {
The text was updated successfully, but these errors were encountered:
Fixes#3388
In GraphQL requests, `extensions` is an optional map.
Passing an explicit `null` was incorrectly considered a parse error.
Now it is equivalent to omiting that field entirely, or to passing an empty map.
Fixes#3388
In GraphQL requests, `extensions` is an optional map.
Passing an explicit `null` was incorrectly considered a parse error.
Now it is equivalent to omiting that field entirely, or to passing an empty map.
Fixes#3388
In GraphQL requests, `extensions` is an optional map. Passing an
explicit `null` was incorrectly considered a parse error. Now it is
equivalent to omiting that field entirely, or to passing an empty map.
<!-- start metadata -->
---
**Checklist**
Complete the checklist (and note appropriate exceptions) before the PR
is marked ready-for-review.
- [ ] Changes are compatible[^1]
- [ ] Documentation[^2] completed
- [ ] Performance impact assessed and acceptable
- Tests added and passing[^3]
- [ ] Unit Tests
- [ ] Integration Tests
- [ ] Manual Tests
**Exceptions**
*Note any exceptions here*
**Notes**
[^1]: It may be appropriate to bring upcoming changes to the attention
of other (impacted) groups. Please endeavour to do this before seeking
PR approval. The mechanism for doing this will vary considerably, so use
your judgement as to how and when to do this.
[^2]: Configuration is an important part of many changes. Where
applicable please try to document configuration examples.
[^3]: Tick whichever testing boxes are applicable. If you are adding
Manual Tests, please document the manual testing (extensively) in the
Exceptions.
---------
Co-authored-by: Bryn Cooke <[email protected]>
Co-authored-by: bryn <[email protected]>
Describe the bug
When making an HTTP POST request with
extensions
field set tonull
Apollo Router returns INVALID_GRAPHQL_REQUEST error:However "GraphQL over HTTP" spec draft says that the
extensions
field is an optional request parameter (https://graphql.github.io/graphql-over-http/draft/#sec-Request-Parameters ). It also says (https://graphql.github.io/graphql-over-http/draft/#note-22957 ):To Reproduce
When specifying
extensions
field in POST request asnull
, the following error is produced:However, omitting
extensions
field works as expected:Expected behavior
Apollo Router should process POST requests with
extensions
field set tonull
as if there was noextensions
field specified.Output
Please, see To reproduce section.
Desktop (please complete the following information):
Additional context
Setting
null_is_default = true
here seems to fix the issue - requests withextensions=null
start working as expected, but this was not thoroughly tested.The text was updated successfully, but these errors were encountered: