diff --git a/.github/workflows/check-init b/.github/workflows/check-init
new file mode 100755
index 00000000000..9c09e84f407
--- /dev/null
+++ b/.github/workflows/check-init
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+set -euo pipefail
+
+cd example/init
+
+go get github.com/99designs/gqlgen
+
+if { go run github.com/99designs/gqlgen init 2>&1 >&3 3>&- | grep '^' >&2; } 3>&1; then
+ echo "gqlgen init failed validation"
+ exit 125
+fi
diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml
index 273e4f5f4e8..8000b49bd50 100644
--- a/.github/workflows/integration.yml
+++ b/.github/workflows/integration.yml
@@ -22,3 +22,11 @@ jobs:
- run: go mod download
- run: cd example/federation ; npm install
- run: .github/workflows/check-federation
+
+ init:
+ runs-on: ubuntu-latest
+ container: golang:1.16-alpine
+ steps:
+ - uses: actions/checkout@v1
+ - run: apk add --no-cache --no-progress alpine-sdk bash
+ - run: .github/workflows/check-init
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 00000000000..263ebc3eb64
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,43 @@
+# Changelog
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
+and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+
+## [Unreleased]
+
+### Added
+
+* Added a changelog :-) Following the same style as [Apollo Client](https://github.com/apollographql/apollo-client) because that feels like it gives good thanks to the community contributors.
+By [@MichaelJCompton](https://github.com/MichaelJCompton) in [#1512](https://github.com/99designs/gqlgen/pull/1512)
+* Added support for methods returning `(v, ok)` shaped values to support Prisma Go client.
+By [@steebchen](https://github.com/steebchen) in [#1449](https://github.com/99designs/gqlgen/pull/1449)
+
+### Changed
+
+* Updated to gqlparser to v2.2.0.
+By [@lwc](https://github.com/lwc) in [#1514](https://github.com/99designs/gqlgen/pull/1514)
+* GraphQL playground updated to 1.7.26.
+By [@ddouglas](https://github.com/ddouglas) in [#1436](https://github.com/99designs/gqlgen/pull/1436)
+
+### Fixed
+
+* Removed a data race by copying when input fields have default values.
+Bu [@skaji](https://github.com/skaji) in [#1456](https://github.com/99designs/gqlgen/pull/1456)
+* v0.12.2 broke the handling of pointers to slices by calling the custom Marshal and Unmarshal functions on the entire slice. It now correctly calls the custom Marshal and Unmarshal methods for each element in the slice.
+By [@ananyasaxena](https://github.com/ananyasaxena) in [#1363](https://github.com/99designs/gqlgen/pull/1363)
+* Changes in go1.16 that mean go.mod and go.sum aren't always up to date. Now `go mod tidy` is run after code generation.
+By [@lwc](https://github.com/lwc) in [#1501](https://github.com/99designs/gqlgen/pull/1501)
+* Errors in resolving non-nullable arrays were not correctly bubbling up to the next nullable field.
+By [@wilhelmeek](https://github.com/wilhelmeek) in [#1480](https://github.com/99designs/gqlgen/pull/1480)
+* Fixed a potential deadlock in calling error presenters.
+By [@vektah](https://github.com/vektah) in [#1399](https://github.com/99designs/gqlgen/pull/1399)
+* Fixed `collectFields` not correctly respecting alias fields in fragments.
+By [@vmrajas](https://github.com/vmrajas) in [#1341](https://github.com/99designs/gqlgen/pull/1341)
+
+
+## [0.13.0] - 2020-09-21
+
+Base version at which changelog was introduced.
+
diff --git a/README.md b/README.md
index b37574b9050..0e04f5557b9 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# gqlgen [![Continuous Integration](https://github.com/99designs/gqlgen/workflows/Continuous%20Integration/badge.svg)](https://github.com/99designs/gqlgen/actions) [![Read the Docs](https://badgen.net/badge/docs/available/green)](http://gqlgen.com/) [![Go Report Card](https://goreportcard.com/badge/github.com/99designs/gqlgen)](https://goreportcard.com/report/github.com/99designs/gqlgen) [![GoDoc](https://godoc.org/github.com/99designs/gqlgen?status.svg)](https://godoc.org/github.com/99designs/gqlgen)
+# gqlgen [![Continuous Integration](https://github.com/99designs/gqlgen/workflows/Continuous%20Integration/badge.svg)](https://github.com/99designs/gqlgen/actions) [![Read the Docs](https://badgen.net/badge/docs/available/green)](http://gqlgen.com/) [![Coverage Status](https://coveralls.io/repos/github/99designs/gqlgen/badge.svg?branch=master)](https://coveralls.io/github/99designs/gqlgen?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/99designs/gqlgen)](https://goreportcard.com/report/github.com/99designs/gqlgen) [![GoDoc](https://godoc.org/github.com/99designs/gqlgen?status.svg)](https://godoc.org/github.com/99designs/gqlgen)
![gqlgen](https://user-images.githubusercontent.com/46195831/89802919-0bb8ef00-db2a-11ea-8ba4-88e7a58b2fd2.png)
diff --git a/TESTING.md b/TESTING.md
index ad7e63352ac..72ba06056c6 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -5,7 +5,7 @@ Testing generated code is a little tricky, heres how its currently set up.
### Testing responses from a server
-There is a server in `codegen/testserver` that is generated as part
+There is a server in `codegen/testserver` that is generated as part
of `go generate ./...`, and tests written against it.
There are also a bunch of tests in against the examples, feel free to take examples from there.
@@ -15,7 +15,7 @@ There are also a bunch of tests in against the examples, feel free to take examp
These tests are **really** slow, because they need to run the whole codegen step. Use them very sparingly. If you can, find a way to unit test it instead.
-Take a look at `codegen/input_test.go` for an example.
+Take a look at `codegen/testserver/input_test.go` for an example.
### Testing introspection
diff --git a/api/generate.go b/api/generate.go
index 3a19c017de9..d9484005173 100644
--- a/api/generate.go
+++ b/api/generate.go
@@ -77,6 +77,9 @@ func Generate(cfg *config.Config, option ...Option) error {
if err = codegen.GenerateCode(data); err != nil {
return errors.Wrap(err, "generating core failed")
}
+ if err = cfg.Packages.ModTidy(); err != nil {
+ return errors.Wrap(err, "tidy failed")
+ }
for _, p := range plugins {
if mut, ok := p.(plugin.CodeGenerator); ok {
diff --git a/codegen/config/binder.go b/codegen/config/binder.go
index 2be7b7bdd6b..6de7ae117a3 100644
--- a/codegen/config/binder.go
+++ b/codegen/config/binder.go
@@ -217,6 +217,14 @@ func (t *TypeReference) IsSlice() bool {
return t.GQL.Elem != nil && isSlice
}
+func (t *TypeReference) IsPtrToSlice() bool {
+ if t.IsPtr() {
+ _, isPointerToSlice := t.GO.(*types.Pointer).Elem().(*types.Slice)
+ return isPointerToSlice
+ }
+ return false
+}
+
func (t *TypeReference) IsNamed() bool {
_, isSlice := t.GO.(*types.Named)
return isSlice
diff --git a/codegen/field.go b/codegen/field.go
index 26ed6b5518a..d1eceb002ef 100644
--- a/codegen/field.go
+++ b/codegen/field.go
@@ -25,6 +25,7 @@ type Field struct {
Args []*FieldArgument // A list of arguments to be passed to this field
MethodHasContext bool // If this is bound to a go method, does the method also take a context
NoErr bool // If this is bound to a go method, does that method have an error as the second argument
+ VOkFunc bool // If this is bound to a go method, is it of shape (interface{}, bool)
Object *Object // A link back to the parent object
Default interface{} // The default value
Stream bool // does this field return a channel?
@@ -152,6 +153,8 @@ func (b *builder) bindField(obj *Object, f *Field) (errret error) {
sig := target.Type().(*types.Signature)
if sig.Results().Len() == 1 {
f.NoErr = true
+ } else if s := sig.Results(); s.Len() == 2 && s.At(1).Type().String() == "bool" {
+ f.VOkFunc = true
} else if sig.Results().Len() != 2 {
return fmt.Errorf("method has wrong number of args")
}
diff --git a/codegen/field.gotpl b/codegen/field.gotpl
index 66f715981a6..8e53772afac 100644
--- a/codegen/field.gotpl
+++ b/codegen/field.gotpl
@@ -112,7 +112,13 @@ func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Contex
return nil, fmt.Errorf("unexpected type %T for field %s", v, {{ .Name | quote}})
}
{{- else if .IsMethod -}}
- {{- if .NoErr -}}
+ {{- if .VOkFunc -}}
+ v, ok := {{.GoReceiverName}}.{{.GoFieldName}}({{ .CallArgs }})
+ if !ok {
+ return nil, nil
+ }
+ return v, nil
+ {{- else if .NoErr -}}
return {{.GoReceiverName}}.{{.GoFieldName}}({{ .CallArgs }}), nil
{{- else -}}
return {{.GoReceiverName}}.{{.GoFieldName}}({{ .CallArgs }})
diff --git a/codegen/input.gotpl b/codegen/input.gotpl
index e8a5b50492b..c6eac4d47bb 100644
--- a/codegen/input.gotpl
+++ b/codegen/input.gotpl
@@ -2,7 +2,10 @@
{{- if not .HasUnmarshal }}
func (ec *executionContext) unmarshalInput{{ .Name }}(ctx context.Context, obj interface{}) ({{.Type | ref}}, error) {
var it {{.Type | ref}}
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
{{ range $field := .Fields}}
{{- if $field.Default}}
if _, present := asMap[{{$field.Name|quote}}] ; !present {
diff --git a/codegen/testserver/directive.graphql b/codegen/testserver/directive.graphql
index 4005cfd8907..f878c4d5cf7 100644
--- a/codegen/testserver/directive.graphql
+++ b/codegen/testserver/directive.graphql
@@ -6,7 +6,7 @@ directive @toNull on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINI
directive @directive1 on FIELD_DEFINITION
directive @directive2 on FIELD_DEFINITION
directive @unimplemented on FIELD_DEFINITION
-directive @order1(location: String!) on FIELD_DEFINITION | OBJECT
+directive @order1(location: String!) repeatable on FIELD_DEFINITION | OBJECT
directive @order2(location: String!) on OBJECT
extend type Query {
@@ -42,7 +42,7 @@ input InnerDirectives {
message: String! @length(min: 1, message: "not valid")
}
-type ObjectDirectives @order1(location: "ObjectDirectives_object_1") @order2(location: "ObjectDirectives_object_2") {
+type ObjectDirectives @order1(location: "order1_1") @order1(location: "order1_2") @order2(location: "order2_1") {
text: String! @length(min: 0, max: 7, message: "not valid")
nullableText: String @toNull
order: [String!]!
diff --git a/codegen/testserver/directive_test.go b/codegen/testserver/directive_test.go
index 32015005104..56786f58037 100644
--- a/codegen/testserver/directive_test.go
+++ b/codegen/testserver/directive_test.go
@@ -387,8 +387,9 @@ func TestDirectives(t *testing.T) {
require.Equal(t, "Ok", resp.DirectiveObject.Text)
require.True(t, resp.DirectiveObject.NullableText == nil)
require.Equal(t, "Query_field", resp.DirectiveObject.Order[0])
- require.Equal(t, "ObjectDirectives_object_2", resp.DirectiveObject.Order[1])
- require.Equal(t, "ObjectDirectives_object_1", resp.DirectiveObject.Order[2])
+ require.Equal(t, "order2_1", resp.DirectiveObject.Order[1])
+ require.Equal(t, "order1_2", resp.DirectiveObject.Order[2])
+ require.Equal(t, "order1_1", resp.DirectiveObject.Order[3])
})
t.Run("when directive returns nil & custom go field is not nilable", func(t *testing.T) {
var resp struct {
diff --git a/codegen/testserver/generated.go b/codegen/testserver/generated.go
index ea3c2f48547..376764a3a48 100644
--- a/codegen/testserver/generated.go
+++ b/codegen/testserver/generated.go
@@ -256,6 +256,10 @@ type ComplexityRoot struct {
Value func(childComplexity int) int
}
+ PtrToSliceContainer struct {
+ PtrToSlice func(childComplexity int) int
+ }
+
Query struct {
Animal func(childComplexity int) int
Autobind func(childComplexity int) int
@@ -278,6 +282,8 @@ type ComplexityRoot struct {
EmbeddedCase3 func(childComplexity int) int
EnumInInput func(childComplexity int, input *InputWithEnumValue) int
ErrorBubble func(childComplexity int) int
+ ErrorBubbleList func(childComplexity int) int
+ ErrorList func(childComplexity int) int
Errors func(childComplexity int) int
Fallback func(childComplexity int, arg FallbackToStringEncoding) int
InputNullableSlice func(childComplexity int, arg []string) int
@@ -300,12 +306,15 @@ type ComplexityRoot struct {
Panics func(childComplexity int) int
PrimitiveObject func(childComplexity int) int
PrimitiveStringObject func(childComplexity int) int
+ PtrToSliceContainer func(childComplexity int) int
Recursive func(childComplexity int, input *RecursiveInputSlice) int
ScalarSlice func(childComplexity int) int
ShapeUnion func(childComplexity int) int
Shapes func(childComplexity int) int
Slices func(childComplexity int) int
User func(childComplexity int, id int) int
+ VOkCaseNil func(childComplexity int) int
+ VOkCaseValue func(childComplexity int) int
Valid func(childComplexity int) int
ValidType func(childComplexity int) int
WrappedMap func(childComplexity int) int
@@ -344,6 +353,14 @@ type ComplexityRoot struct {
Updated func(childComplexity int) int
}
+ VOkCaseNil struct {
+ Value func(childComplexity int) int
+ }
+
+ VOkCaseValue struct {
+ Value func(childComplexity int) int
+ }
+
ValidType struct {
DifferentCase func(childComplexity int) int
DifferentCaseOld func(childComplexity int) int
@@ -457,16 +474,21 @@ type QueryResolver interface {
MapStringInterface(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error)
MapNestedStringInterface(ctx context.Context, in *NestedMapInput) (map[string]interface{}, error)
ErrorBubble(ctx context.Context) (*Error, error)
+ ErrorBubbleList(ctx context.Context) ([]*Error, error)
+ ErrorList(ctx context.Context) ([]*Error, error)
Errors(ctx context.Context) (*Errors, error)
Valid(ctx context.Context) (string, error)
Panics(ctx context.Context) (*Panics, error)
PrimitiveObject(ctx context.Context) ([]Primitive, error)
PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error)
+ PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error)
DefaultScalar(ctx context.Context, arg string) (string, error)
Slices(ctx context.Context) (*Slices, error)
ScalarSlice(ctx context.Context) ([]byte, error)
Fallback(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error)
OptionalUnion(ctx context.Context) (TestUnion, error)
+ VOkCaseValue(ctx context.Context) (*VOkCaseValue, error)
+ VOkCaseNil(ctx context.Context) (*VOkCaseNil, error)
ValidType(ctx context.Context) (*ValidType, error)
WrappedStruct(ctx context.Context) (*WrappedStruct, error)
WrappedScalar(ctx context.Context) (otherpkg.Scalar, error)
@@ -1012,6 +1034,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.PrimitiveString.Value(childComplexity), true
+ case "PtrToSliceContainer.ptrToSlice":
+ if e.complexity.PtrToSliceContainer.PtrToSlice == nil {
+ break
+ }
+
+ return e.complexity.PtrToSliceContainer.PtrToSlice(childComplexity), true
+
case "Query.animal":
if e.complexity.Query.Animal == nil {
break
@@ -1199,6 +1228,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Query.ErrorBubble(childComplexity), true
+ case "Query.errorBubbleList":
+ if e.complexity.Query.ErrorBubbleList == nil {
+ break
+ }
+
+ return e.complexity.Query.ErrorBubbleList(childComplexity), true
+
+ case "Query.errorList":
+ if e.complexity.Query.ErrorList == nil {
+ break
+ }
+
+ return e.complexity.Query.ErrorList(childComplexity), true
+
case "Query.errors":
if e.complexity.Query.Errors == nil {
break
@@ -1393,6 +1436,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Query.PrimitiveStringObject(childComplexity), true
+ case "Query.ptrToSliceContainer":
+ if e.complexity.Query.PtrToSliceContainer == nil {
+ break
+ }
+
+ return e.complexity.Query.PtrToSliceContainer(childComplexity), true
+
case "Query.recursive":
if e.complexity.Query.Recursive == nil {
break
@@ -1445,6 +1495,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Query.User(childComplexity, args["id"].(int)), true
+ case "Query.vOkCaseNil":
+ if e.complexity.Query.VOkCaseNil == nil {
+ break
+ }
+
+ return e.complexity.Query.VOkCaseNil(childComplexity), true
+
+ case "Query.vOkCaseValue":
+ if e.complexity.Query.VOkCaseValue == nil {
+ break
+ }
+
+ return e.complexity.Query.VOkCaseValue(childComplexity), true
+
case "Query.valid":
if e.complexity.Query.Valid == nil {
break
@@ -1623,6 +1687,20 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.User.Updated(childComplexity), true
+ case "VOkCaseNil.value":
+ if e.complexity.VOkCaseNil.Value == nil {
+ break
+ }
+
+ return e.complexity.VOkCaseNil.Value(childComplexity), true
+
+ case "VOkCaseValue.value":
+ if e.complexity.VOkCaseValue.Value == nil {
+ break
+ }
+
+ return e.complexity.VOkCaseValue.Value(childComplexity), true
+
case "ValidType.differentCase":
if e.complexity.ValidType.DifferentCase == nil {
break
@@ -1837,7 +1915,7 @@ directive @toNull on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | FIELD_DEFINI
directive @directive1 on FIELD_DEFINITION
directive @directive2 on FIELD_DEFINITION
directive @unimplemented on FIELD_DEFINITION
-directive @order1(location: String!) on FIELD_DEFINITION | OBJECT
+directive @order1(location: String!) repeatable on FIELD_DEFINITION | OBJECT
directive @order2(location: String!) on OBJECT
extend type Query {
@@ -1873,7 +1951,7 @@ input InnerDirectives {
message: String! @length(min: 1, message: "not valid")
}
-type ObjectDirectives @order1(location: "ObjectDirectives_object_1") @order2(location: "ObjectDirectives_object_2") {
+type ObjectDirectives @order1(location: "order1_1") @order1(location: "order1_2") @order2(location: "order2_1") {
text: String! @length(min: 0, max: 7, message: "not valid")
nullableText: String @toNull
order: [String!]!
@@ -2039,6 +2117,8 @@ input NestedInput {
`, BuiltIn: false},
{Name: "nulls.graphql", Input: `extend type Query {
errorBubble: Error
+ errorBubbleList: [Error!]
+ errorList: [Error]
errors: Errors
valid: String!
}
@@ -2086,6 +2166,14 @@ type PrimitiveString {
doubled: String!
len: Int!
}
+`, BuiltIn: false},
+ {Name: "ptr_to_slice.graphql", Input: `type PtrToSliceContainer {
+ ptrToSlice: [String!]
+}
+
+extend type Query {
+ ptrToSliceContainer: PtrToSliceContainer!
+}
`, BuiltIn: false},
{Name: "scalar_default.graphql", Input: `extend type Query {
defaultScalar(arg: DefaultScalarImplementation! = "default"): DefaultScalarImplementation!
@@ -2204,10 +2292,10 @@ scalar Time
}
type Slices {
- test1: [String]
- test2: [String!]
- test3: [String]!
- test4: [String!]!
+ test1: [String]
+ test2: [String!]
+ test3: [String]!
+ test4: [String!]!
}
scalar Bytes
@@ -2235,6 +2323,19 @@ union TestUnion = A | B
extend type Query {
optionalUnion: TestUnion
}
+`, BuiltIn: false},
+ {Name: "v-ok.graphql", Input: `extend type Query {
+ vOkCaseValue: VOkCaseValue
+ vOkCaseNil: VOkCaseNil
+}
+
+type VOkCaseValue @goModel(model:"testserver.VOkCaseValue") {
+ value: String
+}
+
+type VOkCaseNil @goModel(model:"testserver.VOkCaseNil") {
+ value: String
+}
`, BuiltIn: false},
{Name: "validtypes.graphql", Input: `extend type Query {
validType: ValidType
@@ -5738,6 +5839,35 @@ func (ec *executionContext) _PrimitiveString_len(ctx context.Context, field grap
return ec.marshalNInt2int(ctx, field.Selections, res)
}
+func (ec *executionContext) _PtrToSliceContainer_ptrToSlice(ctx context.Context, field graphql.CollectedField, obj *PtrToSliceContainer) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "PtrToSliceContainer",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.PtrToSlice, nil
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*[]string)
+ fc.Result = res
+ return ec.marshalOString2ᚖᚕstringᚄ(ctx, field.Selections, res)
+}
+
func (ec *executionContext) _Query_invalidIdentifier(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -6439,7 +6569,7 @@ func (ec *executionContext) _Query_directiveObject(ctx context.Context, field gr
return ec.resolvers.Query().DirectiveObject(rctx)
}
directive1 := func(ctx context.Context) (interface{}, error) {
- location, err := ec.unmarshalNString2string(ctx, "ObjectDirectives_object_1")
+ location, err := ec.unmarshalNString2string(ctx, "order1_1")
if err != nil {
return nil, err
}
@@ -6449,16 +6579,26 @@ func (ec *executionContext) _Query_directiveObject(ctx context.Context, field gr
return ec.directives.Order1(ctx, nil, directive0, location)
}
directive2 := func(ctx context.Context) (interface{}, error) {
- location, err := ec.unmarshalNString2string(ctx, "ObjectDirectives_object_2")
+ location, err := ec.unmarshalNString2string(ctx, "order1_2")
+ if err != nil {
+ return nil, err
+ }
+ if ec.directives.Order1 == nil {
+ return nil, errors.New("directive order1 is not implemented")
+ }
+ return ec.directives.Order1(ctx, nil, directive1, location)
+ }
+ directive3 := func(ctx context.Context) (interface{}, error) {
+ location, err := ec.unmarshalNString2string(ctx, "order2_1")
if err != nil {
return nil, err
}
if ec.directives.Order2 == nil {
return nil, errors.New("directive order2 is not implemented")
}
- return ec.directives.Order2(ctx, nil, directive1, location)
+ return ec.directives.Order2(ctx, nil, directive2, location)
}
- directive3 := func(ctx context.Context) (interface{}, error) {
+ directive4 := func(ctx context.Context) (interface{}, error) {
location, err := ec.unmarshalNString2string(ctx, "Query_field")
if err != nil {
return nil, err
@@ -6466,10 +6606,10 @@ func (ec *executionContext) _Query_directiveObject(ctx context.Context, field gr
if ec.directives.Order1 == nil {
return nil, errors.New("directive order1 is not implemented")
}
- return ec.directives.Order1(ctx, nil, directive2, location)
+ return ec.directives.Order1(ctx, nil, directive3, location)
}
- tmp, err := directive3(rctx)
+ tmp, err := directive4(rctx)
if err != nil {
return nil, graphql.ErrorOnPath(ctx, err)
}
@@ -7212,6 +7352,64 @@ func (ec *executionContext) _Query_errorBubble(ctx context.Context, field graphq
return ec.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res)
}
+func (ec *executionContext) _Query_errorBubbleList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().ErrorBubbleList(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.([]*Error)
+ fc.Result = res
+ return ec.marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐErrorᚄ(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_errorList(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().ErrorList(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.([]*Error)
+ fc.Result = res
+ return ec.marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, field.Selections, res)
+}
+
func (ec *executionContext) _Query_errors(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -7366,6 +7564,38 @@ func (ec *executionContext) _Query_primitiveStringObject(ctx context.Context, fi
return ec.marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPrimitiveStringᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) _Query_ptrToSliceContainer(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().PtrToSliceContainer(rctx)
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(*PtrToSliceContainer)
+ fc.Result = res
+ return ec.marshalNPtrToSliceContainer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPtrToSliceContainer(ctx, field.Selections, res)
+}
+
func (ec *executionContext) _Query_defaultScalar(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -7534,6 +7764,64 @@ func (ec *executionContext) _Query_optionalUnion(ctx context.Context, field grap
return ec.marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐTestUnion(ctx, field.Selections, res)
}
+func (ec *executionContext) _Query_vOkCaseValue(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().VOkCaseValue(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*VOkCaseValue)
+ fc.Result = res
+ return ec.marshalOVOkCaseValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐVOkCaseValue(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _Query_vOkCaseNil(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Query",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ IsResolver: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, nil, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Query().VOkCaseNil(rctx)
+ })
+
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*VOkCaseNil)
+ fc.Result = res
+ return ec.marshalOVOkCaseNil2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐVOkCaseNil(ctx, field.Selections, res)
+}
+
func (ec *executionContext) _Query_validType(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -8429,7 +8717,7 @@ func (ec *executionContext) _User_updated(ctx context.Context, field graphql.Col
return ec.marshalOTime2ᚖtimeᚐTime(ctx, field.Selections, res)
}
-func (ec *executionContext) _ValidType_differentCase(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) {
+func (ec *executionContext) _VOkCaseNil_value(ctx context.Context, field graphql.CollectedField, obj *VOkCaseNil) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -8437,31 +8725,32 @@ func (ec *executionContext) _ValidType_differentCase(ctx context.Context, field
}
}()
fc := &graphql.FieldContext{
- Object: "ValidType",
+ Object: "VOkCaseNil",
Field: field,
Args: nil,
- IsMethod: false,
+ IsMethod: true,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return obj.DifferentCase, nil
+ v, ok := obj.Value()
+ if !ok {
+ return nil, nil
+ }
+ return v, nil
})
if resTmp == nil {
- if !graphql.HasFieldError(ctx, fc) {
- ec.Errorf(ctx, "must not be null")
- }
return graphql.Null
}
res := resTmp.(string)
fc.Result = res
- return ec.marshalNString2string(ctx, field.Selections, res)
+ return ec.marshalOString2string(ctx, field.Selections, res)
}
-func (ec *executionContext) _ValidType_different_case(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) {
+func (ec *executionContext) _VOkCaseValue_value(ctx context.Context, field graphql.CollectedField, obj *VOkCaseValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -8469,31 +8758,32 @@ func (ec *executionContext) _ValidType_different_case(ctx context.Context, field
}
}()
fc := &graphql.FieldContext{
- Object: "ValidType",
+ Object: "VOkCaseValue",
Field: field,
Args: nil,
- IsMethod: false,
+ IsMethod: true,
IsResolver: false,
}
ctx = graphql.WithFieldContext(ctx, fc)
resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return obj.DifferentCaseOld, nil
+ v, ok := obj.Value()
+ if !ok {
+ return nil, nil
+ }
+ return v, nil
})
if resTmp == nil {
- if !graphql.HasFieldError(ctx, fc) {
- ec.Errorf(ctx, "must not be null")
- }
return graphql.Null
}
res := resTmp.(string)
fc.Result = res
- return ec.marshalNString2string(ctx, field.Selections, res)
+ return ec.marshalOString2string(ctx, field.Selections, res)
}
-func (ec *executionContext) _ValidType_validInputKeywords(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) {
+func (ec *executionContext) _ValidType_differentCase(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -8509,16 +8799,9 @@ func (ec *executionContext) _ValidType_validInputKeywords(ctx context.Context, f
}
ctx = graphql.WithFieldContext(ctx, fc)
- rawArgs := field.ArgumentMap(ec.Variables)
- args, err := ec.field_ValidType_validInputKeywords_args(ctx, rawArgs)
- if err != nil {
- ec.Error(ctx, err)
- return graphql.Null
- }
- fc.Args = args
resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
ctx = rctx // use context from middleware stack in children
- return obj.ValidInputKeywords, nil
+ return obj.DifferentCase, nil
})
if resTmp == nil {
@@ -8527,12 +8810,12 @@ func (ec *executionContext) _ValidType_validInputKeywords(ctx context.Context, f
}
return graphql.Null
}
- res := resTmp.(bool)
+ res := resTmp.(string)
fc.Result = res
- return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+ return ec.marshalNString2string(ctx, field.Selections, res)
}
-func (ec *executionContext) _ValidType_validArgs(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) {
+func (ec *executionContext) _ValidType_different_case(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
@@ -8548,7 +8831,78 @@ func (ec *executionContext) _ValidType_validArgs(ctx context.Context, field grap
}
ctx = graphql.WithFieldContext(ctx, fc)
- rawArgs := field.ArgumentMap(ec.Variables)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.DifferentCaseOld, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(string)
+ fc.Result = res
+ return ec.marshalNString2string(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ValidType_validInputKeywords(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ValidType",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
+ args, err := ec.field_ValidType_validInputKeywords_args(ctx, rawArgs)
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ fc.Args = args
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.ValidInputKeywords, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
+func (ec *executionContext) _ValidType_validArgs(ctx context.Context, field graphql.CollectedField, obj *ValidType) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "ValidType",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ rawArgs := field.ArgumentMap(ec.Variables)
args, err := ec.field_ValidType_validArgs_args(ctx, rawArgs)
if err != nil {
ec.Error(ctx, err)
@@ -8899,6 +9253,38 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -9831,7 +10217,10 @@ func (ec *executionContext) _iIt_id(ctx context.Context, field graphql.Collected
func (ec *executionContext) unmarshalInputInnerDirectives(ctx context.Context, obj interface{}) (InnerDirectives, error) {
var it InnerDirectives
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -9873,7 +10262,10 @@ func (ec *executionContext) unmarshalInputInnerDirectives(ctx context.Context, o
func (ec *executionContext) unmarshalInputInnerInput(ctx context.Context, obj interface{}) (InnerInput, error) {
var it InnerInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -9893,7 +10285,10 @@ func (ec *executionContext) unmarshalInputInnerInput(ctx context.Context, obj in
func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, obj interface{}) (InputDirectives, error) {
var it InputDirectives
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -10013,7 +10408,10 @@ func (ec *executionContext) unmarshalInputInputDirectives(ctx context.Context, o
func (ec *executionContext) unmarshalInputInputWithEnumValue(ctx context.Context, obj interface{}) (InputWithEnumValue, error) {
var it InputWithEnumValue
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -10033,7 +10431,10 @@ func (ec *executionContext) unmarshalInputInputWithEnumValue(ctx context.Context
func (ec *executionContext) unmarshalInputNestedInput(ctx context.Context, obj interface{}) (NestedInput, error) {
var it NestedInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -10053,7 +10454,10 @@ func (ec *executionContext) unmarshalInputNestedInput(ctx context.Context, obj i
func (ec *executionContext) unmarshalInputNestedMapInput(ctx context.Context, obj interface{}) (NestedMapInput, error) {
var it NestedMapInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -10073,7 +10477,10 @@ func (ec *executionContext) unmarshalInputNestedMapInput(ctx context.Context, ob
func (ec *executionContext) unmarshalInputOuterInput(ctx context.Context, obj interface{}) (OuterInput, error) {
var it OuterInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -10093,7 +10500,10 @@ func (ec *executionContext) unmarshalInputOuterInput(ctx context.Context, obj in
func (ec *executionContext) unmarshalInputRecursiveInputSlice(ctx context.Context, obj interface{}) (RecursiveInputSlice, error) {
var it RecursiveInputSlice
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -10113,7 +10523,10 @@ func (ec *executionContext) unmarshalInputRecursiveInputSlice(ctx context.Contex
func (ec *executionContext) unmarshalInputSpecialInput(ctx context.Context, obj interface{}) (SpecialInput, error) {
var it SpecialInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -10133,7 +10546,10 @@ func (ec *executionContext) unmarshalInputSpecialInput(ctx context.Context, obj
func (ec *executionContext) unmarshalInputValidInput(ctx context.Context, obj interface{}) (ValidInput, error) {
var it ValidInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -11787,6 +12203,30 @@ func (ec *executionContext) _PrimitiveString(ctx context.Context, sel ast.Select
return out
}
+var ptrToSliceContainerImplementors = []string{"PtrToSliceContainer"}
+
+func (ec *executionContext) _PtrToSliceContainer(ctx context.Context, sel ast.SelectionSet, obj *PtrToSliceContainer) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, ptrToSliceContainerImplementors)
+
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("PtrToSliceContainer")
+ case "ptrToSlice":
+ out.Values[i] = ec._PtrToSliceContainer_ptrToSlice(ctx, field, obj)
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
var queryImplementors = []string{"Query"}
func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler {
@@ -12266,6 +12706,28 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
res = ec._Query_errorBubble(ctx, field)
return res
})
+ case "errorBubbleList":
+ field := field
+ out.Concurrently(i, func() (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_errorBubbleList(ctx, field)
+ return res
+ })
+ case "errorList":
+ field := field
+ out.Concurrently(i, func() (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_errorList(ctx, field)
+ return res
+ })
case "errors":
field := field
out.Concurrently(i, func() (res graphql.Marshaler) {
@@ -12330,6 +12792,20 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
}
return res
})
+ case "ptrToSliceContainer":
+ field := field
+ out.Concurrently(i, func() (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_ptrToSliceContainer(ctx, field)
+ if res == graphql.Null {
+ atomic.AddUint32(&invalids, 1)
+ }
+ return res
+ })
case "defaultScalar":
field := field
out.Concurrently(i, func() (res graphql.Marshaler) {
@@ -12394,6 +12870,28 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr
res = ec._Query_optionalUnion(ctx, field)
return res
})
+ case "vOkCaseValue":
+ field := field
+ out.Concurrently(i, func() (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_vOkCaseValue(ctx, field)
+ return res
+ })
+ case "vOkCaseNil":
+ field := field
+ out.Concurrently(i, func() (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Query_vOkCaseNil(ctx, field)
+ return res
+ })
case "validType":
field := field
out.Concurrently(i, func() (res graphql.Marshaler) {
@@ -12620,6 +13118,54 @@ func (ec *executionContext) _User(ctx context.Context, sel ast.SelectionSet, obj
return out
}
+var vOkCaseNilImplementors = []string{"VOkCaseNil"}
+
+func (ec *executionContext) _VOkCaseNil(ctx context.Context, sel ast.SelectionSet, obj *VOkCaseNil) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, vOkCaseNilImplementors)
+
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("VOkCaseNil")
+ case "value":
+ out.Values[i] = ec._VOkCaseNil_value(ctx, field, obj)
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
+var vOkCaseValueImplementors = []string{"VOkCaseValue"}
+
+func (ec *executionContext) _VOkCaseValue(ctx context.Context, sel ast.SelectionSet, obj *VOkCaseValue) graphql.Marshaler {
+ fields := graphql.CollectFields(ec.OperationContext, sel, vOkCaseValueImplementors)
+
+ out := graphql.NewFieldSet(fields)
+ var invalids uint32
+ for i, field := range fields {
+ switch field.Name {
+ case "__typename":
+ out.Values[i] = graphql.MarshalString("VOkCaseValue")
+ case "value":
+ out.Values[i] = ec._VOkCaseValue_value(ctx, field, obj)
+ default:
+ panic("unknown field " + strconv.Quote(field.Name))
+ }
+ }
+ out.Dispatch()
+ if invalids > 0 {
+ return graphql.Null
+ }
+ return out
+}
+
var validTypeImplementors = []string{"ValidType"}
func (ec *executionContext) _ValidType(ctx context.Context, sel ast.SelectionSet, obj *ValidType) graphql.Marshaler {
@@ -12845,6 +13391,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null {
invalids++
}
+ case "isRepeatable":
+ out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -13389,6 +13940,12 @@ func (ec *executionContext) marshalNMarshalPanic2ᚕgithubᚗcomᚋ99designsᚋg
ret[i] = ec.marshalNMarshalPanic2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐMarshalPanic(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -13445,6 +14002,13 @@ func (ec *executionContext) marshalNPrimitive2ᚕgithubᚗcomᚋ99designsᚋgqlg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -13486,9 +14050,30 @@ func (ec *executionContext) marshalNPrimitiveString2ᚕgithubᚗcomᚋ99designs
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
+func (ec *executionContext) marshalNPtrToSliceContainer2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPtrToSliceContainer(ctx context.Context, sel ast.SelectionSet, v PtrToSliceContainer) graphql.Marshaler {
+ return ec._PtrToSliceContainer(ctx, sel, &v)
+}
+
+func (ec *executionContext) marshalNPtrToSliceContainer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐPtrToSliceContainer(ctx context.Context, sel ast.SelectionSet, v *PtrToSliceContainer) graphql.Marshaler {
+ if v == nil {
+ if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ return ec._PtrToSliceContainer(ctx, sel, v)
+}
+
func (ec *executionContext) unmarshalNRecursiveInputSlice2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐRecursiveInputSlice(ctx context.Context, v interface{}) (RecursiveInputSlice, error) {
res, err := ec.unmarshalInputRecursiveInputSlice(ctx, v)
return res, graphql.ErrorOnPath(ctx, err)
@@ -13551,6 +14136,12 @@ func (ec *executionContext) marshalNString2ᚕstringᚄ(ctx context.Context, sel
ret[i] = ec.marshalNString2string(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -13673,6 +14264,13 @@ func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -13774,6 +14372,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -13847,6 +14452,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -13896,6 +14508,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -13937,6 +14556,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -14054,6 +14680,7 @@ func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designs
}
wg.Wait()
+
return ret
}
@@ -14094,6 +14721,13 @@ func (ec *executionContext) marshalOCheckIssue8962ᚕᚖgithubᚗcomᚋ99designs
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -14147,6 +14781,94 @@ func (ec *executionContext) marshalOEmbeddedCase32ᚖgithubᚗcomᚋ99designsᚋ
return ec._EmbeddedCase3(ctx, sel, v)
}
+func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v []*Error) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ return ret
+}
+
+func (ec *executionContext) marshalOError2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐErrorᚄ(ctx context.Context, sel ast.SelectionSet, v []*Error) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ ret := make(graphql.Array, len(v))
+ var wg sync.WaitGroup
+ isLen1 := len(v) == 1
+ if !isLen1 {
+ wg.Add(len(v))
+ }
+ for i := range v {
+ i := i
+ fc := &graphql.FieldContext{
+ Index: &i,
+ Result: &v[i],
+ }
+ ctx := graphql.WithFieldContext(ctx, fc)
+ f := func(i int) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
+ if !isLen1 {
+ defer wg.Done()
+ }
+ ret[i] = ec.marshalNError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx, sel, v[i])
+ }
+ if isLen1 {
+ f(i)
+ } else {
+ go f(i)
+ }
+
+ }
+ wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
+ return ret
+}
+
func (ec *executionContext) marshalOError2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐError(ctx context.Context, sel ast.SelectionSet, v *Error) graphql.Marshaler {
if v == nil {
return graphql.Null
@@ -14359,6 +15081,7 @@ func (ec *executionContext) marshalOOuterObject2ᚕᚕᚖgithubᚗcomᚋ99design
}
wg.Wait()
+
return ret
}
@@ -14399,6 +15122,7 @@ func (ec *executionContext) marshalOOuterObject2ᚕᚖgithubᚗcomᚋ99designs
}
wg.Wait()
+
return ret
}
@@ -14499,6 +15223,7 @@ func (ec *executionContext) marshalOShape2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
return ret
}
@@ -14551,6 +15276,12 @@ func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel
ret[i] = ec.marshalNString2string(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -14605,6 +15336,18 @@ func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel as
return graphql.MarshalString(*v)
}
+func (ec *executionContext) unmarshalOString2ᚖᚕstringᚄ(ctx context.Context, v interface{}) (*[]string, error) {
+ if v == nil {
+ return nil, nil
+ }
+ res, err := ec.unmarshalOString2ᚕstringᚄ(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+}
+
+func (ec *executionContext) marshalOString2ᚖᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v *[]string) graphql.Marshaler {
+ return ec.marshalOString2ᚕstringᚄ(ctx, sel, *v)
+}
+
func (ec *executionContext) marshalOTestUnion2githubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐTestUnion(ctx context.Context, sel ast.SelectionSet, v TestUnion) graphql.Marshaler {
if v == nil {
return graphql.Null
@@ -14642,6 +15385,20 @@ func (ec *executionContext) marshalOTime2ᚖtimeᚐTime(ctx context.Context, sel
return graphql.MarshalTime(*v)
}
+func (ec *executionContext) marshalOVOkCaseNil2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐVOkCaseNil(ctx context.Context, sel ast.SelectionSet, v *VOkCaseNil) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._VOkCaseNil(ctx, sel, v)
+}
+
+func (ec *executionContext) marshalOVOkCaseValue2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐVOkCaseValue(ctx context.Context, sel ast.SelectionSet, v *VOkCaseValue) graphql.Marshaler {
+ if v == nil {
+ return graphql.Null
+ }
+ return ec._VOkCaseValue(ctx, sel, v)
+}
+
func (ec *executionContext) unmarshalOValidInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋcodegenᚋtestserverᚐValidInput(ctx context.Context, v interface{}) (*ValidInput, error) {
if v == nil {
return nil, nil
@@ -14710,6 +15467,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -14750,6 +15514,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -14790,6 +15561,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -14837,6 +15615,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/codegen/testserver/input_test.go b/codegen/testserver/input_test.go
index 1a54508d721..aaba53aa668 100644
--- a/codegen/testserver/input_test.go
+++ b/codegen/testserver/input_test.go
@@ -46,4 +46,24 @@ func TestInput(t *testing.T) {
require.NoError(t, err)
require.False(t, resp.InputNullableSlice)
})
+
+ t.Run("coerce single value to slice", func(t *testing.T) {
+ check := func(ctx context.Context, arg []string) (b bool, e error) {
+ return len(arg) == 1 && arg[0] == "coerced", nil
+ }
+ resolvers.QueryResolver.InputSlice = check
+ resolvers.QueryResolver.InputNullableSlice = check
+
+ var resp struct {
+ Coerced bool
+ }
+ var err error
+ err = c.Post(`query { coerced: inputSlice(arg: "coerced") }`, &resp)
+ require.NoError(t, err)
+ require.True(t, resp.Coerced)
+
+ err = c.Post(`query { coerced: inputNullableSlice(arg: "coerced") }`, &resp)
+ require.NoError(t, err)
+ require.True(t, resp.Coerced)
+ })
}
diff --git a/codegen/testserver/nulls.graphql b/codegen/testserver/nulls.graphql
index d93f6b0cf62..a1fea680ce2 100644
--- a/codegen/testserver/nulls.graphql
+++ b/codegen/testserver/nulls.graphql
@@ -1,5 +1,7 @@
extend type Query {
errorBubble: Error
+ errorBubbleList: [Error!]
+ errorList: [Error]
errors: Errors
valid: String!
}
diff --git a/codegen/testserver/nulls_test.go b/codegen/testserver/nulls_test.go
index e79eecc283a..4822829d174 100644
--- a/codegen/testserver/nulls_test.go
+++ b/codegen/testserver/nulls_test.go
@@ -14,13 +14,18 @@ func TestNullBubbling(t *testing.T) {
resolvers.QueryResolver.Valid = func(ctx context.Context) (s string, e error) {
return "Ok", nil
}
-
resolvers.QueryResolver.Errors = func(ctx context.Context) (errors *Errors, e error) {
return &Errors{}, nil
}
resolvers.QueryResolver.ErrorBubble = func(ctx context.Context) (i *Error, e error) {
return &Error{ID: "E1234"}, nil
}
+ resolvers.QueryResolver.ErrorBubbleList = func(ctx context.Context) (i []*Error, e error) {
+ return []*Error{nil}, nil
+ }
+ resolvers.QueryResolver.ErrorList = func(ctx context.Context) (i []*Error, e error) {
+ return []*Error{nil}, nil
+ }
c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
@@ -68,6 +73,31 @@ func TestNullBubbling(t *testing.T) {
require.Equal(t, "Ok", resp.Valid)
})
+ t.Run("when list element is null", func(t *testing.T) {
+ var resp struct {
+ Valid string
+ ErrorList []*struct{}
+ }
+ err := c.Post(`query { valid, errorList { id } }`, &resp)
+
+ require.Nil(t, err)
+ require.Equal(t, len(resp.ErrorList), 1)
+ require.Nil(t, resp.ErrorList[0])
+ require.Equal(t, "Ok", resp.Valid)
+ })
+
+ t.Run("when non-null list element is null", func(t *testing.T) {
+ var resp struct {
+ Valid string
+ ErrorBubbleList []*struct{}
+ }
+ err := c.Post(`query { valid, errorBubbleList { id } }`, &resp)
+
+ require.EqualError(t, err, `[{"message":"must not be null","path":["errorBubbleList",0]}]`)
+ require.Nil(t, resp.ErrorBubbleList)
+ require.Equal(t, "Ok", resp.Valid)
+ })
+
t.Run("null args", func(t *testing.T) {
var resp struct {
NullableArg *string
@@ -90,7 +120,7 @@ func TestNullBubbling(t *testing.T) {
resolvers.ErrorsResolver.D = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil }
resolvers.ErrorsResolver.E = func(ctx context.Context, obj *Errors) (i *Error, e error) { return nil, nil }
- err := c.Post(`{ errors {
+ err := c.Post(`{ errors {
a { id },
b { id },
c { id },
diff --git a/codegen/testserver/ptr_to_slice.go b/codegen/testserver/ptr_to_slice.go
new file mode 100644
index 00000000000..b16bf48890f
--- /dev/null
+++ b/codegen/testserver/ptr_to_slice.go
@@ -0,0 +1,5 @@
+package testserver
+
+type PtrToSliceContainer struct {
+ PtrToSlice *[]string
+}
diff --git a/codegen/testserver/ptr_to_slice.graphql b/codegen/testserver/ptr_to_slice.graphql
new file mode 100644
index 00000000000..b773d83d428
--- /dev/null
+++ b/codegen/testserver/ptr_to_slice.graphql
@@ -0,0 +1,7 @@
+type PtrToSliceContainer {
+ ptrToSlice: [String!]
+}
+
+extend type Query {
+ ptrToSliceContainer: PtrToSliceContainer!
+}
diff --git a/codegen/testserver/ptr_to_slice_test.go b/codegen/testserver/ptr_to_slice_test.go
new file mode 100644
index 00000000000..2fe498feb8c
--- /dev/null
+++ b/codegen/testserver/ptr_to_slice_test.go
@@ -0,0 +1,37 @@
+package testserver
+
+import (
+ "context"
+ "testing"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+ "github.com/stretchr/testify/require"
+)
+
+func TestPtrToSlice(t *testing.T) {
+ resolvers := &Stub{}
+
+ c := client.New(handler.NewDefaultServer(NewExecutableSchema(Config{Resolvers: resolvers})))
+
+ resolvers.QueryResolver.PtrToSliceContainer = func(ctx context.Context) (wrappedStruct *PtrToSliceContainer, e error) {
+ ptrToSliceContainer := PtrToSliceContainer{
+ PtrToSlice: &[]string{"hello"},
+ }
+ return &ptrToSliceContainer, nil
+ }
+
+ t.Run("pointer to slice", func(t *testing.T) {
+ var resp struct {
+ PtrToSliceContainer struct {
+ PtrToSlice []string
+ }
+ }
+
+ err := c.Post(`query { ptrToSliceContainer { ptrToSlice }}`, &resp)
+ require.NoError(t, err)
+
+ require.Equal(t, []string{"hello"}, resp.PtrToSliceContainer.PtrToSlice)
+
+ })
+}
diff --git a/codegen/testserver/resolver.go b/codegen/testserver/resolver.go
index 952d20943e8..ed813bf511e 100644
--- a/codegen/testserver/resolver.go
+++ b/codegen/testserver/resolver.go
@@ -232,6 +232,14 @@ func (r *queryResolver) ErrorBubble(ctx context.Context) (*Error, error) {
panic("not implemented")
}
+func (r *queryResolver) ErrorBubbleList(ctx context.Context) ([]*Error, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) ErrorList(ctx context.Context) ([]*Error, error) {
+ panic("not implemented")
+}
+
func (r *queryResolver) Errors(ctx context.Context) (*Errors, error) {
panic("not implemented")
}
@@ -252,6 +260,10 @@ func (r *queryResolver) PrimitiveStringObject(ctx context.Context) ([]PrimitiveS
panic("not implemented")
}
+func (r *queryResolver) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) {
+ panic("not implemented")
+}
+
func (r *queryResolver) DefaultScalar(ctx context.Context, arg string) (string, error) {
panic("not implemented")
}
@@ -272,6 +284,14 @@ func (r *queryResolver) OptionalUnion(ctx context.Context) (TestUnion, error) {
panic("not implemented")
}
+func (r *queryResolver) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) {
+ panic("not implemented")
+}
+
+func (r *queryResolver) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) {
+ panic("not implemented")
+}
+
func (r *queryResolver) ValidType(ctx context.Context) (*ValidType, error) {
panic("not implemented")
}
diff --git a/codegen/testserver/slices.graphql b/codegen/testserver/slices.graphql
index 671235d0b37..b1265c56c0b 100644
--- a/codegen/testserver/slices.graphql
+++ b/codegen/testserver/slices.graphql
@@ -4,10 +4,10 @@ extend type Query {
}
type Slices {
- test1: [String]
- test2: [String!]
- test3: [String]!
- test4: [String!]!
+ test1: [String]
+ test2: [String!]
+ test3: [String]!
+ test4: [String!]!
}
scalar Bytes
diff --git a/codegen/testserver/stub.go b/codegen/testserver/stub.go
index daf4052ea08..8b6d7671a26 100644
--- a/codegen/testserver/stub.go
+++ b/codegen/testserver/stub.go
@@ -85,16 +85,21 @@ type Stub struct {
MapStringInterface func(ctx context.Context, in map[string]interface{}) (map[string]interface{}, error)
MapNestedStringInterface func(ctx context.Context, in *NestedMapInput) (map[string]interface{}, error)
ErrorBubble func(ctx context.Context) (*Error, error)
+ ErrorBubbleList func(ctx context.Context) ([]*Error, error)
+ ErrorList func(ctx context.Context) ([]*Error, error)
Errors func(ctx context.Context) (*Errors, error)
Valid func(ctx context.Context) (string, error)
Panics func(ctx context.Context) (*Panics, error)
PrimitiveObject func(ctx context.Context) ([]Primitive, error)
PrimitiveStringObject func(ctx context.Context) ([]PrimitiveString, error)
+ PtrToSliceContainer func(ctx context.Context) (*PtrToSliceContainer, error)
DefaultScalar func(ctx context.Context, arg string) (string, error)
Slices func(ctx context.Context) (*Slices, error)
ScalarSlice func(ctx context.Context) ([]byte, error)
Fallback func(ctx context.Context, arg FallbackToStringEncoding) (FallbackToStringEncoding, error)
OptionalUnion func(ctx context.Context) (TestUnion, error)
+ VOkCaseValue func(ctx context.Context) (*VOkCaseValue, error)
+ VOkCaseNil func(ctx context.Context) (*VOkCaseNil, error)
ValidType func(ctx context.Context) (*ValidType, error)
WrappedStruct func(ctx context.Context) (*WrappedStruct, error)
WrappedScalar func(ctx context.Context) (otherpkg.Scalar, error)
@@ -358,6 +363,12 @@ func (r *stubQuery) MapNestedStringInterface(ctx context.Context, in *NestedMapI
func (r *stubQuery) ErrorBubble(ctx context.Context) (*Error, error) {
return r.QueryResolver.ErrorBubble(ctx)
}
+func (r *stubQuery) ErrorBubbleList(ctx context.Context) ([]*Error, error) {
+ return r.QueryResolver.ErrorBubbleList(ctx)
+}
+func (r *stubQuery) ErrorList(ctx context.Context) ([]*Error, error) {
+ return r.QueryResolver.ErrorList(ctx)
+}
func (r *stubQuery) Errors(ctx context.Context) (*Errors, error) {
return r.QueryResolver.Errors(ctx)
}
@@ -373,6 +384,9 @@ func (r *stubQuery) PrimitiveObject(ctx context.Context) ([]Primitive, error) {
func (r *stubQuery) PrimitiveStringObject(ctx context.Context) ([]PrimitiveString, error) {
return r.QueryResolver.PrimitiveStringObject(ctx)
}
+func (r *stubQuery) PtrToSliceContainer(ctx context.Context) (*PtrToSliceContainer, error) {
+ return r.QueryResolver.PtrToSliceContainer(ctx)
+}
func (r *stubQuery) DefaultScalar(ctx context.Context, arg string) (string, error) {
return r.QueryResolver.DefaultScalar(ctx, arg)
}
@@ -388,6 +402,12 @@ func (r *stubQuery) Fallback(ctx context.Context, arg FallbackToStringEncoding)
func (r *stubQuery) OptionalUnion(ctx context.Context) (TestUnion, error) {
return r.QueryResolver.OptionalUnion(ctx)
}
+func (r *stubQuery) VOkCaseValue(ctx context.Context) (*VOkCaseValue, error) {
+ return r.QueryResolver.VOkCaseValue(ctx)
+}
+func (r *stubQuery) VOkCaseNil(ctx context.Context) (*VOkCaseNil, error) {
+ return r.QueryResolver.VOkCaseNil(ctx)
+}
func (r *stubQuery) ValidType(ctx context.Context) (*ValidType, error) {
return r.QueryResolver.ValidType(ctx)
}
diff --git a/codegen/testserver/v-ok.go b/codegen/testserver/v-ok.go
new file mode 100644
index 00000000000..5ad96bd5b8d
--- /dev/null
+++ b/codegen/testserver/v-ok.go
@@ -0,0 +1,17 @@
+package testserver
+
+// VOkCaseValue model
+type VOkCaseValue struct {
+}
+
+func (v VOkCaseValue) Value() (string, bool) {
+ return "hi", true
+}
+
+// VOkCaseNil model
+type VOkCaseNil struct {
+}
+
+func (v VOkCaseNil) Value() (string, bool) {
+ return "", false
+}
diff --git a/codegen/testserver/v-ok.graphql b/codegen/testserver/v-ok.graphql
new file mode 100644
index 00000000000..0d1530f3636
--- /dev/null
+++ b/codegen/testserver/v-ok.graphql
@@ -0,0 +1,12 @@
+extend type Query {
+ vOkCaseValue: VOkCaseValue
+ vOkCaseNil: VOkCaseNil
+}
+
+type VOkCaseValue @goModel(model:"testserver.VOkCaseValue") {
+ value: String
+}
+
+type VOkCaseNil @goModel(model:"testserver.VOkCaseNil") {
+ value: String
+}
diff --git a/codegen/testserver/v-ok_test.go b/codegen/testserver/v-ok_test.go
new file mode 100644
index 00000000000..fe7037b587d
--- /dev/null
+++ b/codegen/testserver/v-ok_test.go
@@ -0,0 +1,47 @@
+package testserver
+
+import (
+ "context"
+ "testing"
+
+ "github.com/stretchr/testify/require"
+
+ "github.com/99designs/gqlgen/client"
+ "github.com/99designs/gqlgen/graphql/handler"
+)
+
+func TestOk(t *testing.T) {
+ resolver := &Stub{}
+ resolver.QueryResolver.VOkCaseValue = func(ctx context.Context) (*VOkCaseValue, error) {
+ return &VOkCaseValue{}, nil
+ }
+ resolver.QueryResolver.VOkCaseNil = func(ctx context.Context) (*VOkCaseNil, error) {
+ return &VOkCaseNil{}, nil
+ }
+
+ c := client.New(handler.NewDefaultServer(
+ NewExecutableSchema(Config{Resolvers: resolver}),
+ ))
+
+ t.Run("v ok case value", func(t *testing.T) {
+ var resp struct {
+ VOkCaseValue struct {
+ Value string
+ }
+ }
+ err := c.Post(`query { vOkCaseValue { value } }`, &resp)
+ require.NoError(t, err)
+ require.Equal(t, resp.VOkCaseValue.Value, "hi")
+ })
+
+ t.Run("v ok case nil", func(t *testing.T) {
+ var resp struct {
+ VOkCaseNil struct {
+ Value *string
+ }
+ }
+ err := c.Post(`query { vOkCaseNil { value } }`, &resp)
+ require.NoError(t, err)
+ require.Equal(t, true, resp.VOkCaseNil.Value == nil)
+ })
+}
diff --git a/codegen/type.go b/codegen/type.go
index 06b370be7f2..5a059d70131 100644
--- a/codegen/type.go
+++ b/codegen/type.go
@@ -26,7 +26,7 @@ func processType(ret map[string]*config.TypeReference, ref *config.TypeReference
}
ret[key] = ref
- if ref.IsSlice() {
+ if ref.IsSlice() || ref.IsPtrToSlice() {
processType(ret, ref.Elem())
}
}
diff --git a/codegen/type.gotpl b/codegen/type.gotpl
index bd5c8435113..9c421b02d3d 100644
--- a/codegen/type.gotpl
+++ b/codegen/type.gotpl
@@ -4,7 +4,10 @@
{{- if and $type.IsNilable (not $type.GQL.NonNull) }}
if v == nil { return nil, nil }
{{- end }}
- {{- if $type.IsSlice }}
+ {{- if $type.IsPtrToSlice }}
+ res, err := ec.{{ $type.Elem.UnmarshalFunc }}(ctx, v)
+ return &res, graphql.ErrorOnPath(ctx, err)
+ {{- else if $type.IsSlice }}
var vSlice []interface{}
if v != nil {
if tmp1, ok := v.([]interface{}); ok {
@@ -66,7 +69,9 @@
{{ with $type.MarshalFunc }}
func (ec *executionContext) {{ . }}(ctx context.Context, sel ast.SelectionSet, v {{ $type.GO | ref }}) graphql.Marshaler {
- {{- if $type.IsSlice }}
+ {{- if $type.IsPtrToSlice }}
+ return ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, *v)
+ {{- else if $type.IsSlice }}
{{- if not $type.GQL.NonNull }}
if v == nil {
return graphql.Null
@@ -90,11 +95,11 @@
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
- if r := recover(); r != nil {
- ec.Error(ctx, ec.Recover(ctx, r))
- ret = nil
- }
- }()
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = nil
+ }
+ }()
if !isLen1 {
defer wg.Done()
}
@@ -107,9 +112,16 @@
}
{{ else }}
ret[i] = ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, v[i])
- {{- end}}
+ {{- end }}
}
{{ if not $type.IsScalar }} wg.Wait() {{ end }}
+ {{ if $type.Elem.GQL.NonNull }}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+ {{ end }}
return ret
{{- else }}
{{- if $type.IsNilable }}
diff --git a/docs/content/getting-started.md b/docs/content/getting-started.md
index 99a3be37270..5192de632cf 100644
--- a/docs/content/getting-started.md
+++ b/docs/content/getting-started.md
@@ -85,8 +85,8 @@ type Mutation {
### Implement the resolvers
-`gqlgen generate` compares the schema file (`graph/schema.graphqls`) with the models `graph/model/*` and wherever it
-can it will bind directly to the model.
+When executed, gqlgen's `generate` command compares the schema file (`graph/schema.graphqls`) with the models `graph/model/*`, and, wherever it
+can, it will bind directly to the model. That was done alread when `init` was run. We'll edit the schema later in the tutorial, but for now, let's look at what was generated already.
If we take a look in `graph/schema.resolvers.go` we will see all the times that gqlgen couldn't match them up. For us
it was twice:
@@ -103,14 +103,15 @@ func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) {
We just need to implement these two methods to get our server working:
-First we need somewhere to track our state, lets put it in `graph/resolver.go`:
+First we need somewhere to track our state, lets put it in `graph/resolver.go`. The `graph/resolver.go` file is where we declare our app's dependencies, like our database. It gets initialized once in `server.go` when we create the graph.
+
```go
type Resolver struct{
todos []*model.Todo
}
```
-This is where we declare any dependencies for our app like our database, it gets initialized once in `server.go` when
-we create the graph.
+
+Returning to `graph/schema.resolvers.go`, let's implement the bodies of those automatically generated resolver functions. For `CreateTodo`, we'll use `math.rand` to simply return a todo with a randomly generated ID and store that in the in-memory todos list --- in a real app, you're likely to use a database or some other backend service.
```go
func (r *mutationResolver) CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) {
@@ -128,15 +129,17 @@ func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) {
}
```
+### Run the server
+
We now have a working server, to start it:
```bash
go run server.go
```
-then open http://localhost:8080 in a browser. here are some queries to try:
+Open http://localhost:8080 in a browser. Here are some queries to try, starting with creating a todo:
```graphql
mutation createTodo {
- createTodo(input:{text:"todo", userId:"1"}) {
+ createTodo(input: { text: "todo", userId: "1" }) {
user {
id
}
@@ -144,15 +147,19 @@ mutation createTodo {
done
}
}
+```
+
+And then querying for it:
+```graphql
query findTodos {
- todos {
- text
- done
- user {
- name
- }
+ todos {
+ text
+ done
+ user {
+ name
}
+ }
}
```
@@ -205,7 +212,7 @@ At the top of our `resolver.go`, between `package` and `import`, add the followi
//go:generate go run github.com/99designs/gqlgen
```
-This magic comment tells `go generate` what command to run when we want to regenerate our code. To run go generate recursively over your entire project, use this command:
+This magic comment tells `go generate` what command to run when we want to regenerate our code. To run go generate recursively over your entire project, use this command:
```go
go generate ./...
diff --git a/docs/content/recipes/authentication.md b/docs/content/recipes/authentication.md
index 6ae59e73b8d..c77f5d9dd07 100644
--- a/docs/content/recipes/authentication.md
+++ b/docs/content/recipes/authentication.md
@@ -88,7 +88,7 @@ func main() {
router.Use(auth.Middleware(db))
- srv := handler.NewDefaultServer(starwars.NewExecutableSchema(starwars.NewResolver()))
+ srv := handler.NewDefaultServer(starwars.NewExecutableSchema(starwars.NewResolver()))
router.Handle("/", playground.Handler("Starwars", "/query"))
router.Handle("/query", srv)
diff --git a/docs/content/recipes/cors.md b/docs/content/recipes/cors.md
index 9e36110e7e7..0b0ac114bfa 100644
--- a/docs/content/recipes/cors.md
+++ b/docs/content/recipes/cors.md
@@ -22,6 +22,8 @@ import (
"github.com/99designs/gqlgen/graphql/handler"
"github.com/go-chi/chi"
"github.com/rs/cors"
+ "github.com/gorilla/websocket"
+ "github.com/99designs/gqlgen/graphql/playground"
)
func main() {
@@ -48,7 +50,7 @@ func main() {
},
})
- router.Handle("/", handler.Playground("Starwars", "/query"))
+ router.Handle("/", playground.Handler("Starwars", "/query"))
router.Handle("/query", srv)
err := http.ListenAndServe(":8080", router)
diff --git a/docs/content/reference/apq.md b/docs/content/reference/apq.md
index 32df5effc04..f0482949278 100644
--- a/docs/content/reference/apq.md
+++ b/docs/content/reference/apq.md
@@ -14,10 +14,10 @@ to register query hash with original query on a server.
## Usage
In order to enable Automatic Persisted Queries you need to change your client. For more information see
-[Automatic Persisted Queries Link](https://github.com/apollographql/apollo-link-persisted-queries) documentation.
+[Automatic Persisted Queries Link](https://www.apollographql.com/docs/resources/graphql-glossary/#automatic-persisted-queries-apq) documentation.
-For the server you need to implement `PersistedQueryCache` interface and pass instance to
-`handler.EnablePersistedQueryCache` option.
+For the server you need to implement the `graphql.Cache` interface and pass an instance to
+the `extension.AutomaticPersistedQuery` type. Make sure the extension is applied to your GraphQL handler.
See example using [go-redis](https://github.com/go-redis/redis) package below:
```go
@@ -38,7 +38,7 @@ type Cache struct {
const apqPrefix = "apq:"
-func NewCache(redisAddress string, password string, ttl time.Duration) (*Cache, error) {
+func NewCache(redisAddress string, ttl time.Duration) (*Cache, error) {
client := redis.NewClient(&redis.Options{
Addr: redisAddress,
})
diff --git a/docs/content/reference/changesets.md b/docs/content/reference/changesets.md
index 243ab30eb6a..329206ba5ef 100644
--- a/docs/content/reference/changesets.md
+++ b/docs/content/reference/changesets.md
@@ -9,7 +9,7 @@ Occasionally you need to distinguish presence from nil (undefined vs null). In g
```graphql
-type Query {
+type Mutation {
updateUser(id: ID!, changes: UserChanges!): User
}
@@ -28,7 +28,7 @@ models:
After running go generate you should end up with a resolver that looks like this:
```go
-func (r *queryResolver) UpdateUser(ctx context.Context, id int, changes map[string]interface{}) (*User, error) {
+func (r *mutationResolver) UpdateUser(ctx context.Context, id int, changes map[string]interface{}) (*User, error) {
u := fetchFromDb(id)
/// apply the changes
saveToDb(u)
diff --git a/docs/content/reference/complexity.md b/docs/content/reference/complexity.md
index 81367c1cccd..e99ac130587 100644
--- a/docs/content/reference/complexity.md
+++ b/docs/content/reference/complexity.md
@@ -13,13 +13,13 @@ Consider a schema that allows listing blog posts. Each blog post is also related
```graphql
type Query {
- posts(count: Int = 10): [Post!]!
+ posts(count: Int = 10): [Post!]!
}
type Post {
- title: String!
- text: String!
- related(count: Int = 10): [Post!]!
+ title: String!
+ text: String!
+ related(count: Int = 10): [Post!]!
}
```
@@ -27,15 +27,15 @@ It's not too hard to craft a query that will cause a very large response:
```graphql
{
- posts(count: 100) {
- related(count: 100) {
- related(count: 100) {
- related(count: 100) {
- title
- }
- }
- }
- }
+ posts(count: 100) {
+ related(count: 100) {
+ related(count: 100) {
+ related(count: 100) {
+ title
+ }
+ }
+ }
+ }
}
```
@@ -47,12 +47,12 @@ Limiting query complexity is as simple as specifying it with the provided extens
```go
func main() {
- c := Config{ Resolvers: &resolvers{} }
+ c := Config{ Resolvers: &resolvers{} }
srv := handler.NewDefaultServer(blog.NewExecutableSchema(c))
srv.Use(extension.FixedComplexityLimit(5)) // This line is key
- r.Handle("/query", srv)
+ r.Handle("/query", srv)
}
```
@@ -66,17 +66,17 @@ To apply higher costs to certain fields, we can use custom complexity functions.
```go
func main() {
- c := Config{ Resolvers: &resolvers{} }
+ c := Config{ Resolvers: &resolvers{} }
- countComplexity := func(childComplexity, count int) int {
- return count * childComplexity
- }
- c.Complexity.Query.Posts = countComplexity
- c.Complexity.Post.Related = countComplexity
+ countComplexity := func(childComplexity, count int) int {
+ return count * childComplexity
+ }
+ c.Complexity.Query.Posts = countComplexity
+ c.Complexity.Post.Related = countComplexity
- srv := handler.NewDefaultServer(blog.NewExecutableSchema(c))
+ srv := handler.NewDefaultServer(blog.NewExecutableSchema(c))
srv.Use(extension.FixedComplexityLimit(5))
- http.Handle("/query", gqlHandler)
+ http.Handle("/query", gqlHandler)
}
```
diff --git a/docs/content/reference/dataloaders.md b/docs/content/reference/dataloaders.md
index d5ece00e21a..775042eb2ca 100644
--- a/docs/content/reference/dataloaders.md
+++ b/docs/content/reference/dataloaders.md
@@ -157,7 +157,7 @@ func (r *todoResolver) UserLoader(ctx context.Context, obj *model.Todo) (*model.
}
```
-The end result? just 2 queries!
+The end result? Just 2 queries!
```sql
SELECT id, todo, user_id FROM todo
SELECT id, name from user WHERE id IN (?,?,?,?,?)
diff --git a/docs/content/reference/introspection.md b/docs/content/reference/introspection.md
index daa26c6cb01..c1acb1e8160 100644
--- a/docs/content/reference/introspection.md
+++ b/docs/content/reference/introspection.md
@@ -29,7 +29,7 @@ Introspection can also be enabled on a per-request context basis. For example, y
srv := handler.NewDefaultServer(es)
srv.AroundOperations(func(ctx context.Context, next graphql.OperationHandler) graphql.ResponseHandler {
if !userForContext(ctx).IsAdmin {
- graphql.GetOperationContext(ctx).DisableIntrospection = true
+ graphql.GetRequestContext(ctx).DisableIntrospection = true
}
return next(ctx)
diff --git a/example/chat/generated.go b/example/chat/generated.go
index 842b3e31ff9..7ebbf06eb47 100644
--- a/example/chat/generated.go
+++ b/example/chat/generated.go
@@ -1010,6 +1010,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -2162,6 +2197,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null {
invalids++
}
+ case "isRepeatable":
+ out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2447,6 +2487,13 @@ func (ec *executionContext) marshalNMessage2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2528,6 +2575,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2601,6 +2655,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2650,6 +2711,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2691,6 +2759,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2811,6 +2886,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2851,6 +2933,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2891,6 +2980,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2938,6 +3034,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/config/generated.go b/example/config/generated.go
index 4e985ada6b1..5c1c8afad4d 100644
--- a/example/config/generated.go
+++ b/example/config/generated.go
@@ -857,6 +857,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -1809,7 +1844,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co
func (ec *executionContext) unmarshalInputNewTodo(ctx context.Context, obj interface{}) (NewTodo, error) {
var it NewTodo
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -2034,6 +2072,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null {
invalids++
}
+ case "isRepeatable":
+ out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2354,6 +2397,13 @@ func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2415,6 +2465,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2488,6 +2545,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2537,6 +2601,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2578,6 +2649,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2672,6 +2750,12 @@ func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel
ret[i] = ec.marshalNString2string(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2727,6 +2811,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2767,6 +2858,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2807,6 +2905,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2854,6 +2959,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/dataloader/generated.go b/example/dataloader/generated.go
index ef964a60ae8..7ede23b8b1a 100644
--- a/example/dataloader/generated.go
+++ b/example/dataloader/generated.go
@@ -1120,6 +1120,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -2335,6 +2370,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null {
invalids++
}
+ case "isRepeatable":
+ out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2695,6 +2735,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2768,6 +2815,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2817,6 +2871,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2858,6 +2919,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2954,6 +3022,7 @@ func (ec *executionContext) marshalOCustomer2ᚕᚕᚖgithubᚗcomᚋ99designs
}
wg.Wait()
+
return ret
}
@@ -2994,6 +3063,13 @@ func (ec *executionContext) marshalOCustomer2ᚕᚖgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3030,6 +3106,12 @@ func (ec *executionContext) marshalOInt2ᚕintᚄ(ctx context.Context, sel ast.S
ret[i] = ec.marshalNInt2int(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3106,6 +3188,13 @@ func (ec *executionContext) marshalOItem2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3146,6 +3235,13 @@ func (ec *executionContext) marshalOOrder2ᚕᚖgithubᚗcomᚋ99designsᚋgqlge
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3210,6 +3306,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3250,6 +3353,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3290,6 +3400,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3337,6 +3454,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/dataloader/server/server.go b/example/dataloader/server/server.go
index d599330ff90..a11d46a0fe5 100644
--- a/example/dataloader/server/server.go
+++ b/example/dataloader/server/server.go
@@ -7,12 +7,10 @@ import (
"github.com/99designs/gqlgen/example/dataloader"
"github.com/99designs/gqlgen/graphql/handler"
"github.com/99designs/gqlgen/graphql/playground"
- "github.com/go-chi/chi"
)
func main() {
- router := chi.NewRouter()
- router.Use(dataloader.LoaderMiddleware)
+ router := http.NewServeMux()
router.Handle("/", playground.Handler("Dataloader", "/query"))
router.Handle("/query", handler.NewDefaultServer(
@@ -20,5 +18,5 @@ func main() {
))
log.Println("connect to http://localhost:8082/ for graphql playground")
- log.Fatal(http.ListenAndServe(":8082", router))
+ log.Fatal(http.ListenAndServe(":8082", dataloader.LoaderMiddleware(router)))
}
diff --git a/example/federation/accounts/graph/generated/generated.go b/example/federation/accounts/graph/generated/generated.go
index ddc536f26b8..52adf8bb3c5 100644
--- a/example/federation/accounts/graph/generated/generated.go
+++ b/example/federation/accounts/graph/generated/generated.go
@@ -785,6 +785,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -1952,6 +1987,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null {
invalids++
}
+ case "isRepeatable":
+ out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2276,6 +2316,12 @@ func (ec *executionContext) marshalN_Any2ᚕmapᚄ(ctx context.Context, sel ast.
ret[i] = ec.marshalN_Any2map(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2313,6 +2359,7 @@ func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
return ret
}
@@ -2373,6 +2420,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2446,6 +2500,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2495,6 +2556,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2536,6 +2604,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2663,6 +2738,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2703,6 +2785,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2743,6 +2832,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2790,6 +2886,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/federation/products/graph/generated/generated.go b/example/federation/products/graph/generated/generated.go
index 7a62335fdad..5f544afd645 100644
--- a/example/federation/products/graph/generated/generated.go
+++ b/example/federation/products/graph/generated/generated.go
@@ -856,6 +856,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -2028,6 +2063,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null {
invalids++
}
+ case "isRepeatable":
+ out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2352,6 +2392,12 @@ func (ec *executionContext) marshalN_Any2ᚕmapᚄ(ctx context.Context, sel ast.
ret[i] = ec.marshalN_Any2map(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2389,6 +2435,7 @@ func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
return ret
}
@@ -2449,6 +2496,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2522,6 +2576,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2571,6 +2632,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2612,6 +2680,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2716,6 +2791,7 @@ func (ec *executionContext) marshalOProduct2ᚕᚖgithubᚗcomᚋ99designsᚋgql
}
wg.Wait()
+
return ret
}
@@ -2794,6 +2870,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2834,6 +2917,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2874,6 +2964,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2921,6 +3018,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/federation/reviews/graph/generated/generated.go b/example/federation/reviews/graph/generated/generated.go
index 8173a30dd32..0ef7c35a9e9 100644
--- a/example/federation/reviews/graph/generated/generated.go
+++ b/example/federation/reviews/graph/generated/generated.go
@@ -1043,6 +1043,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -2301,6 +2336,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null {
invalids++
}
+ case "isRepeatable":
+ out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2639,6 +2679,12 @@ func (ec *executionContext) marshalN_Any2ᚕmapᚄ(ctx context.Context, sel ast.
ret[i] = ec.marshalN_Any2map(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2676,6 +2722,7 @@ func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
return ret
}
@@ -2736,6 +2783,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2809,6 +2863,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2858,6 +2919,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2899,6 +2967,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2988,6 +3063,7 @@ func (ec *executionContext) marshalOReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlg
}
wg.Wait()
+
return ret
}
@@ -3066,6 +3142,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3106,6 +3189,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3146,6 +3236,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3193,6 +3290,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/fileupload/generated.go b/example/fileupload/generated.go
index 9610785421c..58527eb28d0 100644
--- a/example/fileupload/generated.go
+++ b/example/fileupload/generated.go
@@ -936,6 +936,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -1888,7 +1923,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co
func (ec *executionContext) unmarshalInputUploadFile(ctx context.Context, obj interface{}) (model.UploadFile, error) {
var it model.UploadFile
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -2082,6 +2120,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null {
invalids++
}
+ case "isRepeatable":
+ out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2352,6 +2395,13 @@ func (ec *executionContext) marshalNFile2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2437,6 +2487,12 @@ func (ec *executionContext) marshalNUpload2ᚕᚖgithubᚗcomᚋ99designsᚋgqlg
ret[i] = ec.marshalNUpload2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚐUpload(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2530,6 +2586,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2603,6 +2666,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2652,6 +2722,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2693,6 +2770,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2806,6 +2890,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2846,6 +2937,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2886,6 +2984,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2933,6 +3038,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/init/go.mod b/example/init/go.mod
new file mode 100644
index 00000000000..40eb45b4f85
--- /dev/null
+++ b/example/init/go.mod
@@ -0,0 +1,5 @@
+module gqlgen.com/inittest
+
+go 1.16
+
+replace github.com/99designs/gqlgen => ../..
diff --git a/example/scalars/generated.go b/example/scalars/generated.go
index aa21a4bd1cd..872921a1174 100644
--- a/example/scalars/generated.go
+++ b/example/scalars/generated.go
@@ -1194,6 +1194,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -2146,7 +2181,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co
func (ec *executionContext) unmarshalInputSearchArgs(ctx context.Context, obj interface{}) (model.SearchArgs, error) {
var it model.SearchArgs
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -2391,6 +2429,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null {
invalids++
}
+ case "isRepeatable":
+ out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2754,6 +2797,13 @@ func (ec *executionContext) marshalNUser2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2805,6 +2855,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2878,6 +2935,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2927,6 +2991,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2968,6 +3039,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3184,6 +3262,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3224,6 +3309,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3264,6 +3356,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3311,6 +3410,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/selection/generated.go b/example/selection/generated.go
index 053bf1dbf70..bc3c24d4442 100644
--- a/example/selection/generated.go
+++ b/example/selection/generated.go
@@ -786,6 +786,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -1908,6 +1943,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null {
invalids++
}
+ case "isRepeatable":
+ out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2218,6 +2258,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2291,6 +2338,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2340,6 +2394,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2381,6 +2442,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2470,6 +2538,13 @@ func (ec *executionContext) marshalOEvent2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2515,6 +2590,12 @@ func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel
ret[i] = ec.marshalNString2string(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2570,6 +2651,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2610,6 +2698,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2650,6 +2745,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2697,6 +2799,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/starwars/generated/exec.go b/example/starwars/generated/exec.go
index 3964d7f1069..90dc8645a2a 100644
--- a/example/starwars/generated/exec.go
+++ b/example/starwars/generated/exec.go
@@ -2532,6 +2532,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -3484,7 +3519,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co
func (ec *executionContext) unmarshalInputReviewInput(ctx context.Context, obj interface{}) (models.Review, error) {
var it models.Review
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -4094,6 +4132,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null {
invalids++
}
+ case "isRepeatable":
+ out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -4401,6 +4444,13 @@ func (ec *executionContext) marshalNEpisode2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4500,6 +4550,12 @@ func (ec *executionContext) marshalNInt2ᚕintᚄ(ctx context.Context, sel ast.S
ret[i] = ec.marshalNInt2int(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4530,6 +4586,12 @@ func (ec *executionContext) marshalNInt2ᚕᚕintᚄ(ctx context.Context, sel as
ret[i] = ec.marshalNInt2ᚕintᚄ(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4571,6 +4633,13 @@ func (ec *executionContext) marshalNReview2ᚕᚖgithubᚗcomᚋ99designsᚋgqlg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4633,6 +4702,13 @@ func (ec *executionContext) marshalNSearchResult2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4699,6 +4775,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4772,6 +4855,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4821,6 +4911,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4862,6 +4959,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -4958,6 +5062,13 @@ func (ec *executionContext) marshalOCharacter2ᚕgithubᚗcomᚋ99designsᚋgqlg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -5030,6 +5141,13 @@ func (ec *executionContext) marshalOFriendsEdge2ᚕᚖgithubᚗcomᚋ99designs
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -5140,6 +5258,13 @@ func (ec *executionContext) marshalOStarship2ᚕᚖgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -5235,6 +5360,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -5275,6 +5407,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -5315,6 +5454,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -5362,6 +5508,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/todo/generated.go b/example/todo/generated.go
index cb73c7c6c47..dfb1179ccab 100644
--- a/example/todo/generated.go
+++ b/example/todo/generated.go
@@ -988,6 +988,38 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp := ec._fieldMiddleware(ctx, obj, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -1856,7 +1888,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co
func (ec *executionContext) unmarshalInputTodoInput(ctx context.Context, obj interface{}) (TodoInput, error) {
var it TodoInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -2054,6 +2089,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null {
invalids++
}
+ case "isRepeatable":
+ out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2385,6 +2425,13 @@ func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2441,6 +2488,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2514,6 +2568,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2563,6 +2624,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2604,6 +2672,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2724,6 +2799,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2764,6 +2846,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2804,6 +2893,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2851,6 +2947,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/example/type-system-extension/generated.go b/example/type-system-extension/generated.go
index 2a8cc69338c..ff7ad36e8b5 100644
--- a/example/type-system-extension/generated.go
+++ b/example/type-system-extension/generated.go
@@ -922,6 +922,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -1874,7 +1909,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co
func (ec *executionContext) unmarshalInputTodoInput(ctx context.Context, obj interface{}) (TodoInput, error) {
var it TodoInput
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
for k, v := range asMap {
switch k {
@@ -2088,6 +2126,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null {
invalids++
}
+ case "isRepeatable":
+ out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2398,6 +2441,13 @@ func (ec *executionContext) marshalNTodo2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2454,6 +2504,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2527,6 +2584,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2576,6 +2640,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2617,6 +2688,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2737,6 +2815,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2777,6 +2862,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2817,6 +2909,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2864,6 +2963,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/go.mod b/go.mod
index 3130a194457..bbd03943083 100644
--- a/go.mod
+++ b/go.mod
@@ -3,9 +3,8 @@ module github.com/99designs/gqlgen
go 1.12
require (
- github.com/agnivade/levenshtein v1.0.3 // indirect
- github.com/go-chi/chi v1.5.1
- github.com/gogo/protobuf v1.0.0 // indirect
+ github.com/agnivade/levenshtein v1.1.0 // indirect
+ github.com/gogo/protobuf v1.3.2 // indirect
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f // indirect
github.com/gorilla/mux v1.6.1 // indirect
github.com/gorilla/websocket v1.4.2
@@ -24,9 +23,9 @@ require (
github.com/stretchr/testify v1.4.0
github.com/urfave/cli/v2 v2.1.1
github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e
- github.com/vektah/gqlparser/v2 v2.1.0
- golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589
+ github.com/vektah/gqlparser/v2 v2.2.0
+ golang.org/x/tools v0.0.0-20210106214847-113979e3529a
gopkg.in/yaml.v2 v2.2.4
- sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755
+ sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0
sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 // indirect
)
diff --git a/go.sum b/go.sum
index 8fcfa821c17..fe1fd7471b6 100644
--- a/go.sum
+++ b/go.sum
@@ -1,24 +1,20 @@
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
-github.com/agnivade/levenshtein v1.0.1 h1:3oJU7J3FGFmyhn8KHjmVaZCN5hxTr7GxgRue+sxIXdQ=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
-github.com/agnivade/levenshtein v1.0.3 h1:M5ZnqLOoZR8ygVq0FfkXsNOKzMCk0xRiow0R5+5VkQ0=
-github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs=
+github.com/agnivade/levenshtein v1.1.0 h1:n6qGwyHG61v3ABce1rPVZklEYRT8NFpCMrpZdBUbYGM=
+github.com/agnivade/levenshtein v1.1.0/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
-github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
-github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c h1:TUuUh0Xgj97tLMNtWtNvI9mIV6isjEb9lBMNv+77IGM=
-github.com/dgryski/trifles v0.0.0-20190318185328-a8d75aae118c/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
-github.com/go-chi/chi v1.5.1 h1:kfTK3Cxd/dkMu/rKs5ZceWYp+t5CtiE7vmaTv3LjC6w=
-github.com/go-chi/chi v1.5.1/go.mod h1:REp24E+25iKvxgeTfHmdUoL5x15kBiDBlnIl5bCwe2k=
-github.com/gogo/protobuf v1.0.0 h1:2jyBKDKU/8v3v2xVR2PtiWQviFUyiaGk2rpfyFT8rTM=
-github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
+github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48 h1:fRzb/w+pyskVMQ+UbP35JkH8yB7MYb4q/qhBarqZE6g=
+github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA=
+github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
+github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f h1:9oNbS1z4rVpbnkHBdPZU4jo9bSmrLpII768arSyMFgk=
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/mux v1.6.1 h1:KOwqsTYZdeuMacU7CxjMNYEKeBvLbxW+psodrbcEa3A=
@@ -27,6 +23,8 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0U
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
+github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
+github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -64,7 +62,6 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV
github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0 h1:JJV9CsgM9EC9w2iVkwuz+sMx8yRFe89PJRUrv6hPCIA=
github.com/shurcooL/vfsgen v0.0.0-20180121065927-ffb13db8def0/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/testify v1.2.1 h1:52QO5WkIUcHGIR7EnGagH88x1bUzqGXTC5/1bDTUQ7U=
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
@@ -72,39 +69,52 @@ github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k=
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e h1:+w0Zm/9gaWpEAyDlU1eKOuk5twTjAjuevXqcJJw8hrg=
github.com/vektah/dataloaden v0.2.1-0.20190515034641-a19b9a6e7c9e/go.mod h1:/HUdMve7rvxZma+2ZELQeNh88+003LL7Pf/CZ089j8U=
-github.com/vektah/gqlparser/v2 v2.1.0 h1:uiKJ+T5HMGGQM2kRKQ8Pxw8+Zq9qhhZhz/lieYvCMns=
-github.com/vektah/gqlparser/v2 v2.1.0/go.mod h1:SyUiHgLATUR8BiYURfTirrTcGpcE+4XkV2se04Px1Ms=
+github.com/vektah/gqlparser/v2 v2.2.0 h1:bAc3slekAAJW6sZTi07aGq0OrfaCjj4jxARAaC7g2EM=
+github.com/vektah/gqlparser/v2 v2.2.0/go.mod h1:i3mQIGIrbK2PD1RrCeMTlVbkF2FJ6WkU1KJlJlC+3F4=
+github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
+github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
-golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
-golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
+golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
+golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
+golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
+golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
-golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
+golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
+golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
+golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
-golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
+golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
-golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6 h1:iZgcI2DDp6zW5v9Z/5+f0NuqoxNdmzg4hivjk2WLXpY=
+golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
+golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190125232054-d66bd3c5d5a6/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
-golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd h1:oMEQDWVXVNpceQoVd1JN3CQ7LYJJzs5qWqZIUcxXHHw=
golang.org/x/tools v0.0.0-20190515012406-7d7faa4812bd/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
-golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589 h1:rjUrONFu4kLchcZTfp3/96bR8bW8dIa8uz3cR5n0cgM=
-golang.org/x/tools v0.0.0-20200114235610-7ae403b6b589/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
+golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
+golang.org/x/tools v0.0.0-20210106214847-113979e3529a h1:CB3a9Nez8M13wwlr/E2YtwoU+qYHKfC+JrDa45RXXoQ=
+golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
+golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
-gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
+golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
+golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
-gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
-sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755 h1:d2maSb13hr/ArmfK3rW+wNUKKfytCol7W1/vDHxMPiE=
-sourcegraph.com/sourcegraph/appdash v0.0.0-20180110180208-2cc67fd64755/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
+sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0 h1:ucqkfpjg9WzSUubAO62csmucvxl4/JeW3F4I4909XkM=
+sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67 h1:e1sMhtVq9AfcEy8AXNb8eSg6gbzfdpYhoNqnPJa+GzI=
sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67/go.mod h1:L5q+DGLGOQFpo1snNEkLOJT2d1YTW66rWNzatr3He1k=
diff --git a/graphql/introspection/introspection.go b/graphql/introspection/introspection.go
index 5239c92839e..709fa962630 100644
--- a/graphql/introspection/introspection.go
+++ b/graphql/introspection/introspection.go
@@ -5,10 +5,11 @@ import "github.com/vektah/gqlparser/v2/ast"
type (
Directive struct {
- Name string
- Description string
- Locations []string
- Args []InputValue
+ Name string
+ Description string
+ Locations []string
+ Args []InputValue
+ IsRepeatable bool
}
EnumValue struct {
diff --git a/graphql/introspection/schema.go b/graphql/introspection/schema.go
index 044e91d6e98..bf2b99a0871 100644
--- a/graphql/introspection/schema.go
+++ b/graphql/introspection/schema.go
@@ -1,6 +1,7 @@
package introspection
import (
+ "sort"
"strings"
"github.com/vektah/gqlparser/v2/ast"
@@ -11,12 +12,20 @@ type Schema struct {
}
func (s *Schema) Types() []Type {
- types := make([]Type, 0, len(s.schema.Types))
+ typeIndex := map[string]Type{}
+ typeNames := make([]string, 0, len(s.schema.Types))
for _, typ := range s.schema.Types {
if strings.HasPrefix(typ.Name, "__") {
continue
}
- types = append(types, *WrapTypeFromDef(s.schema, typ))
+ typeNames = append(typeNames, typ.Name)
+ typeIndex[typ.Name] = *WrapTypeFromDef(s.schema, typ)
+ }
+ sort.Strings(typeNames)
+
+ types := make([]Type, len(typeNames))
+ for i, t := range typeNames {
+ types[i] = typeIndex[t]
}
return types
}
@@ -34,10 +43,18 @@ func (s *Schema) SubscriptionType() *Type {
}
func (s *Schema) Directives() []Directive {
- res := make([]Directive, 0, len(s.schema.Directives))
+ dIndex := map[string]Directive{}
+ dNames := make([]string, 0, len(s.schema.Directives))
for _, d := range s.schema.Directives {
- res = append(res, s.directiveFromDef(d))
+ dNames = append(dNames, d.Name)
+ dIndex[d.Name] = s.directiveFromDef(d)
+ }
+ sort.Strings(dNames)
+
+ res := make([]Directive, len(dNames))
+ for i, d := range dNames {
+ res[i] = dIndex[d]
}
return res
@@ -60,9 +77,10 @@ func (s *Schema) directiveFromDef(d *ast.DirectiveDefinition) Directive {
}
return Directive{
- Name: d.Name,
- Description: d.Description,
- Locations: locs,
- Args: args,
+ Name: d.Name,
+ Description: d.Description,
+ Locations: locs,
+ Args: args,
+ IsRepeatable: d.IsRepeatable,
}
}
diff --git a/graphql/uint.go b/graphql/uint.go
new file mode 100644
index 00000000000..9349c2f4d24
--- /dev/null
+++ b/graphql/uint.go
@@ -0,0 +1,81 @@
+package graphql
+
+import (
+ "encoding/json"
+ "fmt"
+ "io"
+ "strconv"
+)
+
+func MarshalUint(i uint) Marshaler {
+ return WriterFunc(func(w io.Writer) {
+ _, _ = io.WriteString(w, strconv.FormatUint(uint64(i), 10))
+ })
+}
+
+func UnmarshalUint(v interface{}) (uint, error) {
+ switch v := v.(type) {
+ case string:
+ u64, err := strconv.ParseUint(v, 10, 64)
+ return uint(u64), err
+ case int:
+ return uint(v), nil
+ case int64:
+ return uint(v), nil
+ case json.Number:
+ u64, err := strconv.ParseUint(string(v), 10, 64)
+ return uint(u64), err
+ default:
+ return 0, fmt.Errorf("%T is not an uint", v)
+ }
+}
+
+func MarshalUint64(i uint64) Marshaler {
+ return WriterFunc(func(w io.Writer) {
+ _, _ = io.WriteString(w, strconv.FormatUint(i, 10))
+ })
+}
+
+func UnmarshalUint64(v interface{}) (uint64, error) {
+ switch v := v.(type) {
+ case string:
+ return strconv.ParseUint(v, 10, 64)
+ case int:
+ return uint64(v), nil
+ case int64:
+ return uint64(v), nil
+ case json.Number:
+ return strconv.ParseUint(string(v), 10, 64)
+ default:
+ return 0, fmt.Errorf("%T is not an uint", v)
+ }
+}
+
+func MarshalUint32(i uint32) Marshaler {
+ return WriterFunc(func(w io.Writer) {
+ _, _ = io.WriteString(w, strconv.FormatUint(uint64(i), 10))
+ })
+}
+
+func UnmarshalUint32(v interface{}) (uint32, error) {
+ switch v := v.(type) {
+ case string:
+ iv, err := strconv.ParseInt(v, 10, 32)
+ if err != nil {
+ return 0, err
+ }
+ return uint32(iv), nil
+ case int:
+ return uint32(v), nil
+ case int64:
+ return uint32(v), nil
+ case json.Number:
+ iv, err := strconv.ParseUint(string(v), 10, 32)
+ if err != nil {
+ return 0, err
+ }
+ return uint32(iv), nil
+ default:
+ return 0, fmt.Errorf("%T is not an uint", v)
+ }
+}
diff --git a/graphql/uint_test.go b/graphql/uint_test.go
new file mode 100644
index 00000000000..98f08ef5261
--- /dev/null
+++ b/graphql/uint_test.go
@@ -0,0 +1,71 @@
+package graphql
+
+import (
+ "encoding/json"
+ "testing"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestUint(t *testing.T) {
+ t.Run("marshal", func(t *testing.T) {
+ assert.Equal(t, "123", m2s(MarshalUint(123)))
+ })
+
+ t.Run("unmarshal", func(t *testing.T) {
+ assert.Equal(t, uint(123), mustUnmarshalUint(123))
+ assert.Equal(t, uint(123), mustUnmarshalUint(int64(123)))
+ assert.Equal(t, uint(123), mustUnmarshalUint(json.Number("123")))
+ assert.Equal(t, uint(123), mustUnmarshalUint("123"))
+ })
+}
+
+func mustUnmarshalUint(v interface{}) uint {
+ res, err := UnmarshalUint(v)
+ if err != nil {
+ panic(err)
+ }
+ return res
+}
+
+func TestUint32(t *testing.T) {
+ t.Run("marshal", func(t *testing.T) {
+ assert.Equal(t, "123", m2s(MarshalUint32(123)))
+ })
+
+ t.Run("unmarshal", func(t *testing.T) {
+ assert.Equal(t, uint32(123), mustUnmarshalUint32(123))
+ assert.Equal(t, uint32(123), mustUnmarshalUint32(int64(123)))
+ assert.Equal(t, uint32(123), mustUnmarshalUint32(json.Number("123")))
+ assert.Equal(t, uint32(123), mustUnmarshalUint32("123"))
+ })
+}
+
+func mustUnmarshalUint32(v interface{}) uint32 {
+ res, err := UnmarshalUint32(v)
+ if err != nil {
+ panic(err)
+ }
+ return res
+}
+
+func TestUint64(t *testing.T) {
+ t.Run("marshal", func(t *testing.T) {
+ assert.Equal(t, "123", m2s(MarshalUint64(123)))
+ })
+
+ t.Run("unmarshal", func(t *testing.T) {
+ assert.Equal(t, uint64(123), mustUnmarshalUint64(123))
+ assert.Equal(t, uint64(123), mustUnmarshalUint64(int64(123)))
+ assert.Equal(t, uint64(123), mustUnmarshalUint64(json.Number("123")))
+ assert.Equal(t, uint64(123), mustUnmarshalUint64("123"))
+ })
+}
+
+func mustUnmarshalUint64(v interface{}) uint64 {
+ res, err := UnmarshalUint64(v)
+ if err != nil {
+ panic(err)
+ }
+ return res
+}
diff --git a/integration/generated.go b/integration/generated.go
index 160d95ced50..ab711d2d507 100644
--- a/integration/generated.go
+++ b/integration/generated.go
@@ -1061,6 +1061,41 @@ func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql
return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res)
}
+func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "__Directive",
+ Field: field,
+ Args: nil,
+ IsMethod: false,
+ IsResolver: false,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return obj.IsRepeatable, nil
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ if !graphql.HasFieldError(ctx, fc) {
+ ec.Errorf(ctx, "must not be null")
+ }
+ return graphql.Null
+ }
+ res := resTmp.(bool)
+ fc.Result = res
+ return ec.marshalNBoolean2bool(ctx, field.Selections, res)
+}
+
func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -2013,7 +2048,10 @@ func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.Co
func (ec *executionContext) unmarshalInputDateFilter(ctx context.Context, obj interface{}) (models.DateFilter, error) {
var it models.DateFilter
- var asMap = obj.(map[string]interface{})
+ asMap := map[string]interface{}{}
+ for k, v := range obj.(map[string]interface{}) {
+ asMap[k] = v
+ }
if _, present := asMap["timezone"]; !present {
asMap["timezone"] = "UTC"
@@ -2324,6 +2362,11 @@ func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionS
if out.Values[i] == graphql.Null {
invalids++
}
+ case "isRepeatable":
+ out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj)
+ if out.Values[i] == graphql.Null {
+ invalids++
+ }
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -2632,6 +2675,12 @@ func (ec *executionContext) marshalNString2ᚕstringᚄ(ctx context.Context, sel
ret[i] = ec.marshalNString2string(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2673,6 +2722,13 @@ func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2746,6 +2802,13 @@ func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2795,6 +2858,13 @@ func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2836,6 +2906,13 @@ func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2906,6 +2983,12 @@ func (ec *executionContext) marshalOBoolean2ᚕboolᚄ(ctx context.Context, sel
ret[i] = ec.marshalNBoolean2bool(ctx, sel, v[i])
}
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -2977,6 +3060,7 @@ func (ec *executionContext) marshalOElement2ᚕᚖgithubᚗcomᚋ99designsᚋgql
}
wg.Wait()
+
return ret
}
@@ -3093,6 +3177,13 @@ func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgq
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3133,6 +3224,13 @@ func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3173,6 +3271,13 @@ func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋg
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
@@ -3220,6 +3325,13 @@ func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgen
}
wg.Wait()
+
+ for _, e := range ret {
+ if e == graphql.Null {
+ return graphql.Null
+ }
+ }
+
return ret
}
diff --git a/integration/package-lock.json b/integration/package-lock.json
index 95a128a71b0..00e48730d7b 100644
--- a/integration/package-lock.json
+++ b/integration/package-lock.json
@@ -3982,14 +3982,37 @@
}
},
"browserslist": {
- "version": "4.14.0",
- "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.14.0.tgz",
- "integrity": "sha512-pUsXKAF2lVwhmtpeA3LJrZ76jXuusrNyhduuQs7CDFf9foT4Y38aQOserd2lMe5DSSrjf3fx34oHwryuvxAUgQ==",
+ "version": "4.17.0",
+ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.17.0.tgz",
+ "integrity": "sha512-g2BJ2a0nEYvEFQC208q8mVAhfNwpZ5Mu8BwgtCdZKO3qx98HChmeg448fPdUzld8aFmfLgVh7yymqV+q1lJZ5g==",
"requires": {
- "caniuse-lite": "^1.0.30001111",
- "electron-to-chromium": "^1.3.523",
- "escalade": "^3.0.2",
- "node-releases": "^1.1.60"
+ "caniuse-lite": "^1.0.30001254",
+ "colorette": "^1.3.0",
+ "electron-to-chromium": "^1.3.830",
+ "escalade": "^3.1.1",
+ "node-releases": "^1.1.75"
+ },
+ "dependencies": {
+ "caniuse-lite": {
+ "version": "1.0.30001255",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001255.tgz",
+ "integrity": "sha512-F+A3N9jTZL882f/fg/WWVnKSu6IOo3ueLz4zwaOPbPYHNmM/ZaDUyzyJwS1mZhX7Ex5jqTyW599Gdelh5PDYLQ=="
+ },
+ "electron-to-chromium": {
+ "version": "1.3.830",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.830.tgz",
+ "integrity": "sha512-gBN7wNAxV5vl1430dG+XRcQhD4pIeYeak6p6rjdCtlz5wWNwDad8jwvphe5oi1chL5MV6RNRikfffBBiFuj+rQ=="
+ },
+ "escalade": {
+ "version": "3.1.1",
+ "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
+ "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw=="
+ },
+ "node-releases": {
+ "version": "1.1.75",
+ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.75.tgz",
+ "integrity": "sha512-Qe5OUajvqrqDSy6wrWFmMwfJ0jVgwiw4T3KqmbTcZ62qW0gQkheXYhcFM1+lOVcGUoRxcEcfyvFMAnDgaF1VWw=="
+ }
}
},
"bser": {
@@ -4122,11 +4145,6 @@
"integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=",
"dev": true
},
- "caniuse-lite": {
- "version": "1.0.30001119",
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001119.tgz",
- "integrity": "sha512-Hpwa4obv7EGP+TjkCh/wVvbtNJewxmtg4yVJBLFnxo35vbPapBr138bUWENkb5j5L9JZJ9RXLn4OrXRG/cecPQ=="
- },
"capture-exit": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/capture-exit/-/capture-exit-2.0.0.tgz",
@@ -4313,6 +4331,11 @@
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
},
+ "colorette": {
+ "version": "1.3.0",
+ "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.3.0.tgz",
+ "integrity": "sha512-ecORCqbSFP7Wm8Y6lyqMJjexBQqXSF7SSeaTyGGphogUjBlFP9m9o08wy86HL2uB7fMTxtOUzLMk7ogKcxMg1w=="
+ },
"columnify": {
"version": "1.5.4",
"resolved": "https://registry.npmjs.org/columnify/-/columnify-1.5.4.tgz",
@@ -5031,11 +5054,6 @@
"integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=",
"dev": true
},
- "electron-to-chromium": {
- "version": "1.3.553",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.553.tgz",
- "integrity": "sha512-wi/hoMuTGK6OJoLOHqmXFA9BWOQGF2nInCfk+/Owhd4VVfuenKE2LZr9TtFCmwyda2SE9hG+sRnqRCwhYgFeIg=="
- },
"emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
@@ -5129,11 +5147,6 @@
"es6-promise": "^4.0.3"
}
},
- "escalade": {
- "version": "3.0.2",
- "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.0.2.tgz",
- "integrity": "sha512-gPYAU37hYCUhW5euPeR+Y74F7BL+IBsV93j5cvGriSaD1aG6MGsqsV1yamRdrWrb2j3aiZvb0X+UBOWpx3JWtQ=="
- },
"escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
@@ -6218,9 +6231,9 @@
}
},
"hosted-git-info": {
- "version": "2.8.5",
- "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz",
- "integrity": "sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==",
+ "version": "2.8.9",
+ "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
+ "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==",
"dev": true
},
"html-encoding-sniffer": {
@@ -6396,9 +6409,9 @@
"dev": true
},
"ini": {
- "version": "1.3.5",
- "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
- "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
+ "version": "1.3.8",
+ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz",
+ "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==",
"dev": true
},
"inquirer": {
@@ -7037,9 +7050,9 @@
}
},
"y18n": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz",
- "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==",
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
+ "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
"dev": true
},
"yargs": {
@@ -7427,9 +7440,9 @@
}
},
"y18n": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz",
- "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==",
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",
+ "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",
"dev": true
},
"yargs": {
@@ -8298,9 +8311,9 @@
}
},
"node-fetch": {
- "version": "2.6.0",
- "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz",
- "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==",
+ "version": "2.6.1",
+ "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
+ "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
"dev": true
},
"node-int64": {
@@ -8328,11 +8341,6 @@
"which": "^1.3.0"
}
},
- "node-releases": {
- "version": "1.1.60",
- "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.60.tgz",
- "integrity": "sha512-gsO4vjEdQaTusZAEebUWp2a5d7dF5DYoIpDG7WySnk7BuZDW+GPpHXoXXuYawRBr/9t5q54tirPz79kFIWg4dA=="
- },
"node-request-by-swagger": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/node-request-by-swagger/-/node-request-by-swagger-1.1.4.tgz",
@@ -8361,9 +8369,9 @@
}
},
"normalize-url": {
- "version": "4.5.0",
- "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.0.tgz",
- "integrity": "sha512-2s47yzUxdexf1OhyRi4Em83iQk0aPvwTddtFz4hnSSw9dCEsLEGf6SwIO8ss/19S9iBb5sJaOuTvTGDeZI00BQ==",
+ "version": "4.5.1",
+ "resolved": "https://registry.npmjs.org/normalize-url/-/normalize-url-4.5.1.tgz",
+ "integrity": "sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA==",
"dev": true
},
"npm-path": {
@@ -8908,9 +8916,9 @@
"dev": true
},
"path-parse": {
- "version": "1.0.6",
- "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
- "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
+ "version": "1.0.7",
+ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
+ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
"dev": true
},
"path-to-regexp": {
@@ -10177,9 +10185,9 @@
"dev": true
},
"tar": {
- "version": "6.0.5",
- "resolved": "https://registry.npmjs.org/tar/-/tar-6.0.5.tgz",
- "integrity": "sha512-0b4HOimQHj9nXNEAA7zWwMM91Zhhba3pspja6sQbgTpynOJf+bkjBnfybNYzbpLbnwXnbyB4LOREvlyXLkCHSg==",
+ "version": "6.1.11",
+ "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.11.tgz",
+ "integrity": "sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==",
"dev": true,
"requires": {
"chownr": "^2.0.0",
@@ -11037,9 +11045,9 @@
}
},
"ws": {
- "version": "7.3.1",
- "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz",
- "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==",
+ "version": "7.4.6",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz",
+ "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==",
"dev": true
},
"xdg-basedir": {
@@ -11061,9 +11069,9 @@
"dev": true
},
"y18n": {
- "version": "3.2.1",
- "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz",
- "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=",
+ "version": "3.2.2",
+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.2.tgz",
+ "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==",
"dev": true
},
"yallist": {
diff --git a/integration/package.json b/integration/package.json
index 8c8c6d365b8..3b4892d182b 100644
--- a/integration/package.json
+++ b/integration/package.json
@@ -14,9 +14,9 @@
"graphql-cli": "^3.0.14",
"graphql-tag": "^2.11.0",
"jest": "^24.9.0",
- "node-fetch": "^2.6.0",
+ "node-fetch": "^2.6.1",
"subscriptions-transport-ws": "^0.9.18",
- "ws": "^7.3.1"
+ "ws": "^7.4.6"
},
"dependencies": {
"@babel/preset-env": "^7.11.0"
diff --git a/internal/code/packages.go b/internal/code/packages.go
index b14c45ad276..d3a4058530b 100644
--- a/internal/code/packages.go
+++ b/internal/code/packages.go
@@ -2,6 +2,7 @@ package code
import (
"bytes"
+ "os/exec"
"path/filepath"
"github.com/pkg/errors"
@@ -149,6 +150,15 @@ func (p *Packages) Evict(importPath string) {
}
}
+func (p *Packages) ModTidy() error {
+ p.packages = nil
+ tidyCmd := exec.Command("go", "mod", "tidy")
+ if err := tidyCmd.Run(); err != nil {
+ return errors.Wrap(err, "go mod tidy failed")
+ }
+ return nil
+}
+
// Errors returns any errors that were returned by Load, either from the call itself or any of the loaded packages.
func (p *Packages) Errors() PkgErrors {
var res []error //nolint:prealloc