aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/99designs/gqlgen/graphql
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/99designs/gqlgen/graphql')
-rw-r--r--vendor/github.com/99designs/gqlgen/graphql/any.go19
-rw-r--r--vendor/github.com/99designs/gqlgen/graphql/context.go4
-rw-r--r--vendor/github.com/99designs/gqlgen/graphql/exec.go19
-rw-r--r--vendor/github.com/99designs/gqlgen/graphql/introspection/type.go4
-rw-r--r--vendor/github.com/99designs/gqlgen/graphql/time.go4
-rw-r--r--vendor/github.com/99designs/gqlgen/graphql/upload.go26
-rw-r--r--vendor/github.com/99designs/gqlgen/graphql/version.go2
7 files changed, 67 insertions, 11 deletions
diff --git a/vendor/github.com/99designs/gqlgen/graphql/any.go b/vendor/github.com/99designs/gqlgen/graphql/any.go
new file mode 100644
index 00000000..6ea8bf2e
--- /dev/null
+++ b/vendor/github.com/99designs/gqlgen/graphql/any.go
@@ -0,0 +1,19 @@
+package graphql
+
+import (
+ "encoding/json"
+ "io"
+)
+
+func MarshalAny(v interface{}) Marshaler {
+ return WriterFunc(func(w io.Writer) {
+ err := json.NewEncoder(w).Encode(v)
+ if err != nil {
+ panic(err)
+ }
+ })
+}
+
+func UnmarshalAny(v interface{}) (interface{}, error) {
+ return v, nil
+}
diff --git a/vendor/github.com/99designs/gqlgen/graphql/context.go b/vendor/github.com/99designs/gqlgen/graphql/context.go
index 58d3c741..356f5175 100644
--- a/vendor/github.com/99designs/gqlgen/graphql/context.go
+++ b/vendor/github.com/99designs/gqlgen/graphql/context.go
@@ -132,14 +132,14 @@ func WithResolverContext(ctx context.Context, rc *ResolverContext) context.Conte
// This is just a convenient wrapper method for CollectFields
func CollectFieldsCtx(ctx context.Context, satisfies []string) []CollectedField {
resctx := GetResolverContext(ctx)
- return CollectFields(ctx, resctx.Field.Selections, satisfies)
+ return CollectFields(GetRequestContext(ctx), resctx.Field.Selections, satisfies)
}
// CollectAllFields returns a slice of all GraphQL field names that were selected for the current resolver context.
// The slice will contain the unique set of all field names requested regardless of fragment type conditions.
func CollectAllFields(ctx context.Context) []string {
resctx := GetResolverContext(ctx)
- collected := CollectFields(ctx, resctx.Field.Selections, nil)
+ collected := CollectFields(GetRequestContext(ctx), resctx.Field.Selections, nil)
uniq := make([]string, 0, len(collected))
Next:
for _, f := range collected {
diff --git a/vendor/github.com/99designs/gqlgen/graphql/exec.go b/vendor/github.com/99designs/gqlgen/graphql/exec.go
index 17c57bf6..3e00a4d5 100644
--- a/vendor/github.com/99designs/gqlgen/graphql/exec.go
+++ b/vendor/github.com/99designs/gqlgen/graphql/exec.go
@@ -19,12 +19,12 @@ type ExecutableSchema interface {
// CollectFields returns the set of fields from an ast.SelectionSet where all collected fields satisfy at least one of the GraphQL types
// passed through satisfies. Providing an empty or nil slice for satisfies will return collect all fields regardless of fragment
// type conditions.
-func CollectFields(ctx context.Context, selSet ast.SelectionSet, satisfies []string) []CollectedField {
- return collectFields(GetRequestContext(ctx), selSet, satisfies, map[string]bool{})
+func CollectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies []string) []CollectedField {
+ return collectFields(reqCtx, selSet, satisfies, map[string]bool{})
}
func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies []string, visited map[string]bool) []CollectedField {
- var groupedFields []CollectedField
+ groupedFields := make([]CollectedField, 0, len(selSet))
for _, sel := range selSet {
switch sel := sel.(type) {
@@ -32,7 +32,7 @@ func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies []
if !shouldIncludeNode(sel.Directives, reqCtx.Variables) {
continue
}
- f := getOrCreateField(&groupedFields, sel.Alias, func() CollectedField {
+ f := getOrCreateAndAppendField(&groupedFields, sel.Alias, func() CollectedField {
return CollectedField{Field: sel}
})
@@ -45,7 +45,7 @@ func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies []
continue
}
for _, childField := range collectFields(reqCtx, sel.SelectionSet, satisfies, visited) {
- f := getOrCreateField(&groupedFields, childField.Name, func() CollectedField { return childField })
+ f := getOrCreateAndAppendField(&groupedFields, childField.Name, func() CollectedField { return childField })
f.Selections = append(f.Selections, childField.Selections...)
}
@@ -70,10 +70,9 @@ func collectFields(reqCtx *RequestContext, selSet ast.SelectionSet, satisfies []
}
for _, childField := range collectFields(reqCtx, fragment.SelectionSet, satisfies, visited) {
- f := getOrCreateField(&groupedFields, childField.Name, func() CollectedField { return childField })
+ f := getOrCreateAndAppendField(&groupedFields, childField.Name, func() CollectedField { return childField })
f.Selections = append(f.Selections, childField.Selections...)
}
-
default:
panic(fmt.Errorf("unsupported %T", sel))
}
@@ -97,7 +96,7 @@ func instanceOf(val string, satisfies []string) bool {
return false
}
-func getOrCreateField(c *[]CollectedField, name string, creator func() CollectedField) *CollectedField {
+func getOrCreateAndAppendField(c *[]CollectedField, name string, creator func() CollectedField) *CollectedField {
for i, cf := range *c {
if cf.Alias == name {
return &(*c)[i]
@@ -111,6 +110,10 @@ func getOrCreateField(c *[]CollectedField, name string, creator func() Collected
}
func shouldIncludeNode(directives ast.DirectiveList, variables map[string]interface{}) bool {
+ if len(directives) == 0 {
+ return true
+ }
+
skip, include := false, true
if d := directives.ForName("skip"); d != nil {
diff --git a/vendor/github.com/99designs/gqlgen/graphql/introspection/type.go b/vendor/github.com/99designs/gqlgen/graphql/introspection/type.go
index f1228edf..9aceebdc 100644
--- a/vendor/github.com/99designs/gqlgen/graphql/introspection/type.go
+++ b/vendor/github.com/99designs/gqlgen/graphql/introspection/type.go
@@ -70,6 +70,10 @@ func (t *Type) Fields(includeDeprecated bool) []Field {
continue
}
+ if !includeDeprecated && f.Directives.ForName("deprecated") != nil {
+ continue
+ }
+
var args []InputValue
for _, arg := range f.Arguments {
args = append(args, InputValue{
diff --git a/vendor/github.com/99designs/gqlgen/graphql/time.go b/vendor/github.com/99designs/gqlgen/graphql/time.go
index 4f448560..9945f3fb 100644
--- a/vendor/github.com/99designs/gqlgen/graphql/time.go
+++ b/vendor/github.com/99designs/gqlgen/graphql/time.go
@@ -8,6 +8,10 @@ import (
)
func MarshalTime(t time.Time) Marshaler {
+ if t.IsZero() {
+ return Null
+ }
+
return WriterFunc(func(w io.Writer) {
io.WriteString(w, strconv.Quote(t.Format(time.RFC3339)))
})
diff --git a/vendor/github.com/99designs/gqlgen/graphql/upload.go b/vendor/github.com/99designs/gqlgen/graphql/upload.go
new file mode 100644
index 00000000..22d61031
--- /dev/null
+++ b/vendor/github.com/99designs/gqlgen/graphql/upload.go
@@ -0,0 +1,26 @@
+package graphql
+
+import (
+ "fmt"
+ "io"
+)
+
+type Upload struct {
+ File io.Reader
+ Filename string
+ Size int64
+}
+
+func MarshalUpload(f Upload) Marshaler {
+ return WriterFunc(func(w io.Writer) {
+ io.Copy(w, f.File)
+ })
+}
+
+func UnmarshalUpload(v interface{}) (Upload, error) {
+ upload, ok := v.(Upload)
+ if !ok {
+ return Upload{}, fmt.Errorf("%T is not an Upload", v)
+ }
+ return upload, nil
+}
diff --git a/vendor/github.com/99designs/gqlgen/graphql/version.go b/vendor/github.com/99designs/gqlgen/graphql/version.go
index 88014abf..11dc6b01 100644
--- a/vendor/github.com/99designs/gqlgen/graphql/version.go
+++ b/vendor/github.com/99designs/gqlgen/graphql/version.go
@@ -1,3 +1,3 @@
package graphql
-const Version = "v0.8.3"
+const Version = "v0.9.0"