Skip to content

Implement GraphQL Introspection Field and Type System #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions types/introspection-field.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
package types

// IntrospectionField represents a field in a GraphQL object or interface type.
type IntrospectionField struct {
Name string `json:"name"`
Description string `json:"description"`
Args []IntrospectionInputValue `json:"args"`
Type IntrospectionInputTypeRef `json:"type"`
IsDeprecated bool `json:"isDeprecated"`
DeprecationReason string `json:"deprecationReason"`
}
2 changes: 1 addition & 1 deletion types/introspection-schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ type IntrospectionSchema struct {
QueryType IntrospectionObjectType `json:"queryType"`
MutationType IntrospectionObjectType `json:"mutationType"`
SubscriptionType IntrospectionObjectType `json:"subscriptionType"`
Types IntrospectionType `json:"types"`
Types []IntrospectionType `json:"types"`
Directives []IntrospectionDirective `json:"directives"`
}
61 changes: 37 additions & 24 deletions types/introspection-type.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,41 +10,54 @@ type IntrospectionScalarType struct {
SpecifiedByURL string `json:"specifiedByURL"`
}

// TypeRef represents a reference to a type in the schema
type TypeRef struct {
Name string `json:"name"`
Kind string `json:"kind"`
}

type IntrospectionObjectType struct {
Kind string `json:"kind"`
Name string `json:"name"`
Description string `json:"description"`
Fields IntrospectionField `json:"fields"`
Interfaces interface{} `json:"interfaces"`
Kind string `json:"kind"`
Name string `json:"name"`
Description string `json:"description"`
Fields []IntrospectionField `json:"fields"`
Interfaces []TypeRef `json:"interfaces"`
}

type IntrospectionInterfaceType struct {
Kind string `json:"kind"`
Name string `json:"name"`
Description string `json:"description"`
Fields IntrospectionField `json:"fields"`
Interfaces interface{} `json:"interfaces"`
// possibleTypes IntrospectionObjectType `json:"possibleTypes"`
Kind string `json:"kind"`
Name string `json:"name"`
Description string `json:"description"`
Fields []IntrospectionField `json:"fields"`
Interfaces []TypeRef `json:"interfaces"`
PossibleTypes []TypeRef `json:"possibleTypes"`
}

type IntrospectionUnionType struct {
Kind string `json:"kind"`
Name string `json:"name"`
Description string `json:"description"`
PossibleTypes IntrospectionObjectType `json:"possibleTypes"`
Kind string `json:"kind"`
Name string `json:"name"`
Description string `json:"description"`
PossibleTypes []TypeRef `json:"possibleTypes"`
}

type IntrospectionEnumValue struct {
Name string `json:"name"`
Description string `json:"description"`
IsDeprecated bool `json:"isDeprecated"`
DeprecationReason string `json:"deprecationReason"`
}

type IntrospectionEnumType struct {
Kind string `json:"kind"`
Name string `json:"name"`
Description string `json:"description"`
// enumValues IntrospectionEnumValue `json:"enumValues"`
Kind string `json:"kind"`
Name string `json:"name"`
Description string `json:"description"`
EnumValues []IntrospectionEnumValue `json:"enumValues"`
}

type IntrospectionInputObjectType struct {
Kind string `json:"kind"`
Name string `json:"name"`
Description string `json:"description"`
// inputFields IntrospectionInputValue `json:"inputFields"`
IsOneOf bool `json:"isOneOf"`
Kind string `json:"kind"`
Name string `json:"name"`
Description string `json:"description"`
InputFields []IntrospectionInputValue `json:"inputFields"`
IsOneOf bool `json:"isOneOf"`
}