mapping

package
v0.0.0-...-f3986d2 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

FieldInfo defines how fields of Go structs map to GraphQL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldInfo

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

FieldInfo defines how a field of a Go struct maps to GraphQL, both when constructing operations (queries/mutations) and when unmarshalling the response.

func NewFieldInfo

func NewFieldInfo(f reflect.StructField) FieldInfo

NewFieldInfo maps a field of a Go struct to GraphQL.

func (FieldInfo) FieldName

func (f FieldInfo) FieldName() string

FieldName names the field in GraphQL. Aliases are not supported.

func (FieldInfo) GraphQL

func (f FieldInfo) GraphQL() string

GraphQL returns a GraphQL snippet. Recall that Go structs correspond to selection sets in GraphQL and Go struct fields corresond to selections. See https://spec.graphql.org/October2021/#sec-Selection-Sets. In particular, the returned GraphQL snippet satisfies the InlineFragment or Field production in the language, except for the trailing SelectionSet. For example, this can return "... on User" or "name".

func (FieldInfo) Inline

func (f FieldInfo) Inline() bool

Inline returns true if the Go struct field has a struct type (i.e. a struct contained in a struct) and the "inner" struct fields should be "inlined" in the "outer" struct fields when constructing GraphQL selection sets.

func (FieldInfo) IsInlineFragment

func (f FieldInfo) IsInlineFragment() bool

IsInlineFragment returns true if f.GraphQL() is an InlineFragment production (without the trailing selection set). I.e. the field of the Go struct defines an inline fragment. See https://spec.graphql.org/October2021/#sec-Selection-Sets.

Jump to

Keyboard shortcuts

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