Skip to Content
GraphQL Tools
DocumentationAPI@graphql-tools/utilssrcfunctionsisDocumentString

Function: isDocumentString()

isDocumentString(str): boolean

Defined in: packages/utils/src/helpers.ts:51

Determines if a given input is a valid GraphQL document string.

Parameters

str

any

The input to validate as a GraphQL document

Returns

boolean

A boolean indicating whether the input is a valid GraphQL document string

Remarks

This function performs several validation checks:

  • Ensures the input is a string
  • Filters out strings with invalid document extensions
  • Excludes URLs
  • Attempts to parse the string as a GraphQL document

Throws

If the document fails to parse and is empty except GraphQL comments