Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Operation Name #147

Open
cliedeman opened this issue Mar 11, 2022 · 0 comments
Open

Missing Operation Name #147

cliedeman opened this issue Mar 11, 2022 · 0 comments

Comments

@cliedeman
Copy link
Contributor

My Graphql Backend expects an operationName field to be sent, this aligns with the graphql-over-http draft spec

Current patch I am using

diff --git a/node_modules/react-relay-network-modern/es/RelayRequest.js b/node_modules/react-relay-network-modern/es/RelayRequest.js
index 2197cea..af6454a 100644
--- a/node_modules/react-relay-network-modern/es/RelayRequest.js
+++ b/node_modules/react-relay-network-modern/es/RelayRequest.js
@@ -46,6 +46,7 @@ export default class RelayRequest {
       const formData = new _FormData_();
       formData.append('id', this.getID());
       formData.append('query', this.getQueryString());
+      formData.append('operationName', this.operation.name);
       formData.append('variables', JSON.stringify(this.getVariables()));
       Object.keys(uploadables).forEach(key => {
         if (Object.prototype.hasOwnProperty.call(uploadables, key)) {
@@ -58,7 +59,8 @@ export default class RelayRequest {
     return JSON.stringify({
       id: this.getID(),
       query: this.getQueryString(),
-      variables: this.getVariables()
+      variables: this.getVariables(),
+      operationName: this.operation.name,
     });
   }

I suggest adding a variable on RelayRequest that will include this field when added

Ciaran

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant