module Analyzer::Specification::GraphqlSdlParser

Overview

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.

Extended Modules

Defined in:

analyzer/analyzers/specification/graphql_sdl_parser.cr

Constant Summary

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 Method Summary

Instance Method Detail

def 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.


[View source]