module

Analyzer::Specification::GraphqlSdlParser

Shared GraphQL SDL parser. Extracted from GraphqlSdl so other analyzers (Apollo Server's inline gql\...`` typeDefs, Yoga, etc.) can produce the same field-per-endpoint shape without re-implementing the SDL grammar.

Constants

DEFAULT_GRAPHQL_PATH = "/graphql"
ROOT_OPERATIONS = {"Query" => "query", "Mutation" => "mutation", "Subscription" => "subscription"}

Root operation type → GraphQL operation keyword. All operations ride on POST (Noir's URL optimizer dedupes on method+url and the HTTP method allowlist doesn't include WS); subscriptions are flagged via endpoint.protocol = "ws" and a tag instead.

Instance methods

field_endpoint(file_path : String, line : Int32 | Nil, root_kind : String, field_name : String, args : Array(NamedTuple(name: String, type: String)), return_type : String, tag_source : String, default_path : String = DEFAULT_GRAPHQL_PATH, type_name : String = root_kind) : Endpoint

One root field of a code-first schema (Strawberry, Graphene, HotChocolate, graphql-ruby, Absinthe), which has no SDL to parse: the host analyzer collects the field itself and gets the same endpoint shape as an SDL field. root_kind is "Query", "Mutation" or "Subscription"; type_name is the schema's name for that root when it differs.

Source
parse(content : String, file_path : String, default_path : String = DEFAULT_GRAPHQL_PATH, tag_source : String = "graphql_sdl_analyzer", line_offset : Int32 = 0) : Array(Endpoint)

Parse an SDL document and return one endpoint per Query/Mutation/Subscription field. line_offset shifts every reported line number — used by host analyzers (e.g. Apollo Server) whose SDL is embedded in a larger file.

Source
skip_ws(chars : Array(Char), pos : Int32) : Int32

Walks the materialized char array (see cluster entry points) — O(1) per access where String#[](Int) is O(n) on non-ASCII content. Also used by GraphqlTypedefs.

Source