refinedev/refine · error · Error

GraphQL need to operation, fields and variables values in me

Error message

GraphQL need to operation, fields and variables values in meta object.

What it means

The hasura data provider's custom() method requires the meta object to include operation, fields, and variables. This error is thrown when meta itself (or any of its required members) is missing entirely, so the provider cannot construct a GraphQL request. All three keys are mandatory even if empty.

Source

Thrown at packages/hasura/src/dataProvider/index.ts:631

          }
          const { query, variables } = gql.mutation({
            operation: meta.operation,
            fields: meta.fields,
            variables: meta.variables,
          });

          const response = await gqlClient.request<BaseRecord>(
            query,
            variables,
          );

          return {
            data: response[meta.operation],
          };
        }
        throw Error("GraphQL operation name required.");
      }
      throw Error(
        "GraphQL need to operation, fields and variables values in meta object.",
      );
    },
  };
};

export default dataProvider;

View on GitHub (pinned to 779d52a20e)

Solutions

  1. Pass a complete meta object: { operation, fields, variables } — supply empty arrays/objects for unused parts
  2. Confirm you are on @refinedev/hasura and reading its custom() docs, not the generic data provider docs
  3. If you just need a raw HTTP call, use your own fetch/axios instead of custom()

Example fix

// before
await dataProvider.custom({ url: "/x", method: "post" });

// after
await dataProvider.custom({
  url: "",
  method: "post",
  meta: { operation: "deleteUser", fields: ["id"], variables: { id: 1 } },
});
Defensive patterns

Strategy: validation

Validate before calling

const metaOk = !!meta && ["operation","fields","variables"].every((k) => k in meta);

Type guard

const isCustomMeta = (m: unknown): m is { operation: string; fields: any[]; variables: Record<string, unknown> } =>
  typeof m === "object" && m !== null && "operation" in m && "fields" in m && "variables" in m;

Try / catch

try { await dataProvider.custom({ url, method, meta }); } catch (e) { if (String(e).includes("meta object")) { /* supply full meta */ } else throw e; }

Prevention

When it happens

Trigger: Calling custom({ url, method }) with no meta at all, or meta missing fields/variables (e.g. only passing operation).

Common situations: Treating custom() like the REST providers' custom() which takes a plain URL; upgrading refine versions where the meta contract became strict; copying examples from strapi/airtable providers.

Related errors


AI-assisted analysis of refinedev/refine@779d52a20e (2026-08-27). Data as JSON: /api/errors/f072db999b0b5be4. Report an issue: GitHub.