Home / Function/ validateGraphQLRequest() — supabase Function Reference

validateGraphQLRequest() — supabase Function Reference

Architecture documentation for the validateGraphQLRequest() function in route.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  87d3c8b4_1926_050c_c177_ae099c77a929["validateGraphQLRequest()"]
  9f23b9c2_5895_763f_0113_465855239c31["handleGraphQLRequest()"]
  9f23b9c2_5895_763f_0113_465855239c31 -->|calls| 87d3c8b4_1926_050c_c177_ae099c77a929
  style 87d3c8b4_1926_050c_c177_ae099c77a929 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/app/api/graphql/route.ts lines 213–251

function validateGraphQLRequest(
  query: string,
  options?: {
    isDevGraphiQL?: boolean
    isGetRequest?: boolean
    operationName?: string
  }
): ReadonlyArray<GraphQLError> {
  let documentAST: DocumentNode
  try {
    documentAST = parse(query)
  } catch (error: unknown) {
    if (error instanceof GraphQLError) {
      return [error]
    } else {
      throw error
    }
  }
  const rules = options?.isDevGraphiQL ? specifiedRules : validationRules
  const validationErrors = validate(rootGraphQLSchema, documentAST, rules)
  if (!options?.isGetRequest) {
    return validationErrors
  }

  const operationAST = getOperationAST(documentAST, options.operationName)
  if (!operationAST) {
    return [
      ...validationErrors,
      new GraphQLError(
        'GET requests must specify an operation name or send only a single operation'
      ),
    ]
  }
  if (operationAST.operation !== 'query') {
    return [...validationErrors, new GraphQLError('GET requests may only execute query operations')]
  }

  return validationErrors
}

Subdomains

Frequently Asked Questions

What does validateGraphQLRequest() do?
validateGraphQLRequest() is a function in the supabase codebase.
What calls validateGraphQLRequest()?
validateGraphQLRequest() is called by 1 function(s): handleGraphQLRequest.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free