shopify_draft_proxy/graphql/parse_operation

Mirrors src/graphql/parse-operation.ts.

Lightweight façade over the parser that extracts just the bits the proxy’s dispatcher needs from an operation document: operation type (query/mutation), optional operation name, and the names of the root selection fields.

Subscriptions are explicitly rejected — the TS proxy does not handle them and neither does the port.

Types

Operation kinds the proxy actually supports. Subscriptions are absent by design — see parse_operation for the rejection.

pub type GraphQLOperationType {
  QueryOperation
  MutationOperation
}

Constructors

  • QueryOperation
  • MutationOperation

Reasons parse_operation can fail. Distinct from parser.ParseError so callers can disambiguate “couldn’t parse the document” from “parsed fine but the document isn’t usable here”.

pub type ParseOperationError {
  ParseFailed(parser.ParseError)
  NoOperationFound
  UnsupportedOperation(String)
}

Constructors

Result of summarising an operation document.

pub type ParsedOperation {
  ParsedOperation(
    type_: GraphQLOperationType,
    name: option.Option(String),
    root_fields: List(String),
  )
}

Constructors

Values

pub fn parse_operation(
  document: String,
) -> Result(ParsedOperation, ParseOperationError)

Parse document and summarise the first operation definition.

Mirrors parseOperation in parse-operation.ts: finds the first OperationDefinition, rejects anything other than query/mutation, and projects the root selection set down to the names of its FieldNode selections (fragment spreads and inline fragments are dropped, matching the TS .filter(kind === Kind.FIELD)).

Search Document