{"record":{"id":"40a963b9f34439ea","repo":"refinedev/refine","slug":"graphql-operation-name-required","errorCode":null,"errorMessage":"GraphQL operation name required.","messagePattern":"GraphQL operation name required\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/hasura/src/dataProvider/index.ts","lineNumber":629,"sourceCode":"              data: response[meta.operation],\n            };\n          }\n          const { query, variables } = gql.mutation({\n            operation: meta.operation,\n            fields: meta.fields,\n            variables: meta.variables,\n          });\n\n          const response = await gqlClient.request<BaseRecord>(\n            query,\n            variables,\n          );\n\n          return {\n            data: response[meta.operation],\n          };\n        }\n        throw Error(\"GraphQL operation name required.\");\n      }\n      throw Error(\n        \"GraphQL need to operation, fields and variables values in meta object.\",\n      );\n    },\n  };\n};\n\nexport default dataProvider;\n","sourceCodeStart":611,"sourceCodeEnd":639,"githubUrl":"https://github.com/refinedev/refine/blob/779d52a20e29b0307ac0df04d135beba434370dc/packages/hasura/src/dataProvider/index.ts#L611-L639","documentation":"The hasura data provider's custom() method requires a meta object containing an operation name. It throws when meta is provided but meta.operation is missing, because the provider must know which key of the GraphQL response to return. The operation name must match the field/alias in the returned GraphQL payload.","triggerScenarios":"Calling resources.custom({ url, method, meta: { fields, variables } }) without meta.operation, or with a typo'd key like meta.operationName. Happens when the meta object lacks the operation property while fields/variables exist.","commonSituations":"Migrating custom() calls from another provider where meta only carried query variables; typos in meta keys; assuming the provider infers the operation from the query string.","solutions":["Add meta.operation set to the name of the root field returned by your GraphQL query, e.g. { operation: \"myQuery\", fields, variables }","Verify the value matches a top-level key in the response payload so response[meta.operation] resolves","Check for typos such as operationName vs operation"],"exampleFix":"// before\nawait dataProvider.custom({ url: \"\", method: \"post\", meta: { fields: [\"id\"], variables: {} } });\n\n// after\nawait dataProvider.custom({ url: \"\", method: \"post\", meta: { operation: \"users\", fields: [\"id\", \"name\"], variables: { limit: 1 } } });","handlingStrategy":"validation","validationCode":"const hasOperation = (meta?: any): meta is { operation: string } =>\n  !!meta && typeof meta.operation === \"string\" && meta.operation.length > 0;\nif (!hasOperation(meta)) throw new Error(\"custom() requires meta.operation\");","typeGuard":"const isCustomMeta = (m: unknown): m is { operation: string; fields: any[]; variables: Record<string, unknown> } =>\n  typeof m === \"object\" && m !== null && \"operation\" in m && \"fields\" in m && \"variables\" in m;","tryCatchPattern":"try { await dataProvider.custom({ url, method, meta }); } catch (e) { if (String(e).includes(\"operation name required\")) { /* fix meta.operation and retry */ } else throw e; }","preventionTips":["Always construct meta with all three keys: operation, fields, variables","Write a small helper buildCustomMeta(operation, fields, variables) used by every custom() call"],"tags":["refine","hasura","graphql","meta","custom-query"],"backgroundTag":"missing-graphql-operation-meta","analyzedSha":"779d52a20e29b0307ac0df04d135beba434370dc","analyzedAt":"2026-08-27T11:15:25.854Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}