Persisted queries not compatible with Relay #44
-
Screenshot Configuration:
Expected Behaviour Library is compatible with Relay which requires to set an "id" property in the request parameters (and "query" probably to null). Actual Behaviour Relay throws an error because the "id" property is missing and no valid query has been specified. When Relay is configured to use persisted queries, the "operation.text" property is automatically set to null and only the "id" is provided. The "RequestParams" interface does not allow an "id" property and also query cannot be set to null. https://relay.dev/docs/guides/persisted-queries/ Therefore persisted queries is currently not usable with this library. For fetching I am able to get it working by writing my own fetch function:
Is there any way to get it working with Relay? On my GraphQL server I can make a custom middleware to get the ID out of the extensions, but as long as Relay is throwing an error I can't get it to work at all. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The What you should do is set an empty string to the I reckon the error you're getting is originating from the servers response, not the request. You can confirm that by hooking up on the |
Beta Was this translation helpful? Give feedback.
The
query
field is required to be coherent with the GraphQL over HTTP spec.What you should do is set an empty string to the
query
parameter and provide the persisted query ID within theextensions
(exactly like you already do). The network layer is separate from Relay, it does not care about how you structure your request.I reckon the error you're getting is originating from the servers response, not the request. You can confirm that by hooking up on the
sink.error
orsink.next
and checking theerrors
field.