typer

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 8, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package typer is responsible for converting GraphQL schema types and query selections into Argo wire types. It processes GraphQL operations (queries, mutations, subscriptions) and their associated fragments to determine the static Argo type structure for the expected response, including handling of Argo-specific directives for codec and deduplication control.

Index

Constants

This section is empty.

Variables

ArgoDirectives lists the custom Argo-specific directives that the Typer recognizes and processes.

Functions

This section is empty.

Types

type SelectedFieldNode

type SelectedFieldNode struct {
	SelectedBy ast.Selection // The AST node (Field, FragmentSpread, InlineFragment) that selected this field.
	Field      *ast.Field    // The actual ast.Field that was selected.
}

SelectedFieldNode represents a GraphQL field that is part of a selection set, along with the AST node (Field, FragmentSpread, or InlineFragment) that caused it to be selected. This is used during the collection of fields to track the origin of each selected field, which is important for resolving type conditions and merging fields from different paths.

type Typer

type Typer struct {
	// contains filtered or unexported fields
}

Typer translates GraphQL schema definitions and query documents into Argo wire types. It holds the context of the current GraphQL schema, the query document being processed, fragment definitions, and the resolved Argo wire types for various parts of the query. The Typer focuses on a single operation within the query document.

func NewTyper

func NewTyper(s *ast.Schema, q *ast.QueryDocument, operationName ...string) (*Typer, error)

NewTyper creates a new Typer for a given GraphQL schema, query document, and operation name. If the query document contains multiple operations, an operationName must be provided. It initializes fragment definitions and identifies the target operation.

func (*Typer) DataWireType

func (t *Typer) DataWireType() (wire.Type, error)

DataWireType computes the Argo wire.Type specifically for the 'data' part of a GraphQL response, based on the operation's selection set against the root operation type.

func (*Typer) Operation

func (t *Typer) Operation() *ast.OperationDefinition

Operation returns the specific *ast.OperationDefinition that this Typer instance is processing.

func (*Typer) RootType

func (t *Typer) RootType() (*ast.Definition, error)

RootType determines the root GraphQL object type (e.g., Query, Mutation, Subscription) for the current operation being processed by the Typer.

func (*Typer) RootWireType

func (t *Typer) RootWireType() (wire.Type, error)

RootWireType computes the top-level Argo wire.Type for the entire GraphQL response, which includes both the 'data' and 'errors' fields, according to the GraphQL specification.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL