nextauthjs/next-auth · error

Hasura client error: Please provide a graphql endpoint

Error message

Hasura client error: Please provide a graphql endpoint

What it means

The Hasura adapter client needs the GraphQL endpoint URL to send queries. If HasuraAdapter options omit endpoint (or it is empty), client() throws this TypeError at construction. This is a pure configuration validation error thrown before any network call.

Source

Thrown at packages/adapter-hasura/src/lib/client.ts:30

export class HasuraClientError extends Error {
  name = "HasuraClientError"
  constructor(
    errors: any[],
    query: TypedDocumentString<any, any>,
    variables: any
  ) {
    super(errors.map((error) => error.message).join("\n"))
    console.error({ query, variables })
  }
}

export function client({ adminSecret, endpoint }: HasuraAdapterClient) {
  if (!adminSecret)
    throw new TypeError("Hasura client error: Please provide an adminSecret")

  if (!endpoint)
    throw new TypeError(
      "Hasura client error: Please provide a graphql endpoint"
    )

  return {
    async run<
      Q extends TypedDocumentString<any, any>,
      T extends Q extends TypedDocumentString<infer T, any> ? T : never,
      V extends Q extends TypedDocumentString<any, infer V> ? V : never,
    >(query: Q, variables?: V): Promise<T> {
      const response = await fetch(endpoint, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "x-hasura-admin-secret": adminSecret,
        },
        body: JSON.stringify({ query, variables }),
      })

View on GitHub (pinned to a1a16a5a77)

Solutions

  1. Set endpoint to the Hasura GraphQL URL (e.g. https://<project>.hasura.app/v1/graphql) in HasuraAdapter options
  2. Ensure the environment variable is defined in the deployment environment and actually loaded at runtime
  3. Verify the URL is the /v1/graphql endpoint, not the console or metadata URL
  4. Fail fast at startup with an assertion if endpoint is missing

Example fix

// before
HasuraAdapter({ adminSecret: process.env.HASURA_ADMIN_SECRET! })
// after
HasuraAdapter({
  adminSecret: process.env.HASURA_ADMIN_SECRET!,
  endpoint: process.env.HASURA_ENDPOINT!,
})
Defensive patterns

Strategy: validation

Validate before calling

if (!process.env.HASURA_ENDPOINT) {
  throw new Error('HASURA_ENDPOINT is not set')
}
const adapter = HasuraAdapter({
  endpoint: process.env.HASURA_ENDPOINT,
  adminSecret: process.env.HASURA_ADMIN_SECRET!,
})

Type guard

function isValidEndpoint(v: unknown): v is string {
  return typeof v === 'string' && v.startsWith('http') && v.includes('/v1/graphql')
}

Try / catch

try {
  const adapter = HasuraAdapter({ adminSecret, endpoint: process.env.HASURA_ENDPOINT! })
} catch (e) {
  if (e instanceof TypeError && e.message.includes('graphql endpoint')) {
    console.error('HASURA_ENDPOINT must point to /v1/graphql')
  } else throw e
}

Prevention

When it happens

Trigger: HasuraAdapter({ adminSecret }) without endpoint; endpoint: process.env.HASURA_ENDPOINT with the env var unset; typos in the env var name; building the options object conditionally and dropping endpoint.

Common situations: Deploying to a new environment (staging/preview) without copying HASURA_ENDPOINT; mixing up GraphQL vs console URLs; forgetting NEXT_PUBLIC/runtime env configuration in serverless platforms.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of nextauthjs/next-auth@a1a16a5a77 (2026-08-28). Data as JSON: /api/errors/984b5c7570cc7f1c. Report an issue: GitHub.