From bf2d07a47fa57b27434a02021ca8ed868019ba9c Mon Sep 17 00:00:00 2001 From: Quest Henkart Date: Wed, 1 May 2019 10:41:59 +0200 Subject: [PATCH] moves naming convention to a non-go standard --- codegen/config/config.go | 6 +++--- docs/content/reference/scalars.md | 6 +++--- graphql/{interface.go => any.go} | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) rename graphql/{interface.go => any.go} (63%) diff --git a/codegen/config/config.go b/codegen/config/config.go index 51c088787d6..502422de440 100644 --- a/codegen/config/config.go +++ b/codegen/config/config.go @@ -363,9 +363,9 @@ func (c *Config) InjectBuiltins(s *ast.Schema) { // These are additional types that are injected if defined in the schema as scalars. extraBuiltins := TypeMap{ - "Time": {Model: StringList{"github.com/99designs/gqlgen/graphql.Time"}}, - "Map": {Model: StringList{"github.com/99designs/gqlgen/graphql.Map"}}, - "Interface": {Model: StringList{"github.com/99designs/gqlgen/graphql.Interface"}}, + "Time": {Model: StringList{"github.com/99designs/gqlgen/graphql.Time"}}, + "Map": {Model: StringList{"github.com/99designs/gqlgen/graphql.Map"}}, + "Any": {Model: StringList{"github.com/99designs/gqlgen/graphql.Any"}}, } for typeName, entry := range extraBuiltins { diff --git a/docs/content/reference/scalars.md b/docs/content/reference/scalars.md index 888a3bd4d92..0ac35d4d53a 100644 --- a/docs/content/reference/scalars.md +++ b/docs/content/reference/scalars.md @@ -7,7 +7,7 @@ menu: { main: { parent: 'reference' } } ## Built-in helpers -gqlgen ships with three built-in helpers for common custom scalar use-cases, `Time`, `Interface` and `Map`. Adding any of these to a schema will automatically add the marshalling behaviour to Go types. +gqlgen ships with three built-in helpers for common custom scalar use-cases, `Time`, `Any` and `Map`. Adding any of these to a schema will automatically add the marshalling behaviour to Go types. ### Time @@ -25,10 +25,10 @@ scalar Map Maps an arbitrary GraphQL value to a `map[string]{interface}` Go type. -### Interface +### Any ```graphql -scalar Interface +scalar Any ``` Maps an arbitrary GraphQL value to a `interface{}` Go type. diff --git a/graphql/interface.go b/graphql/any.go similarity index 63% rename from graphql/interface.go rename to graphql/any.go index 0dfdb80a4dc..6ea8bf2eaeb 100644 --- a/graphql/interface.go +++ b/graphql/any.go @@ -5,7 +5,7 @@ import ( "io" ) -func MarshalInterface(v interface{}) Marshaler { +func MarshalAny(v interface{}) Marshaler { return WriterFunc(func(w io.Writer) { err := json.NewEncoder(w).Encode(v) if err != nil { @@ -14,6 +14,6 @@ func MarshalInterface(v interface{}) Marshaler { }) } -func UnmarshalInterface(v interface{}) (interface{}, error) { +func UnmarshalAny(v interface{}) (interface{}, error) { return v, nil }