Skip to content

GraphQL Analyzer

dagster_authkit.core.graphql_analyzer

GraphQL Mutation Analyzer using official parser for robust detection. Replaces fragile regex-based approach with AST parsing to accurately identify mutations.

GraphQLMutationAnalyzer

Robust GraphQL mutation detection using official parser. Replaces fragile regex approach.

extract_mutation_names staticmethod

extract_mutation_names(query, operation_name=None)

Extract ALL mutation field names from a GraphQL query. Returns sentinel set with UNPARSEABLE_QUERY if query is invalid. Returns empty set if query has no mutations.

If operation_name is provided, only the named operation is analyzed. This prevents false-positive RBAC blocks when a document contains both query and mutation operations but only the query is executed.

Examples:

>>> extract_mutation_names("mutation { launchRun deleteRun }")
{'launchRun', 'deleteRun'}
>>> extract_mutation_names("query GetRuns { ... } mutation DoStuff { launchRun }",
...                        operation_name="GetRuns")
set()

is_parseable staticmethod

is_parseable(query)

Check if a GraphQL query can be successfully parsed.

Returns:

Type Description
bool

True if the query is valid GraphQL syntax, False otherwise.

is_mutation staticmethod

is_mutation(query)

Check if query contains mutations.

Returns False for unparseable or empty queries to prevent treating parser failures as mutations (security).