Skip to content

Missing Operation Name #147

@cliedeman

Description

@cliedeman

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions