Skip to content

Commit

Permalink
Merge pull request 99designs#882 from 99designs/testserver-autobind
Browse files Browse the repository at this point in the history
Use autobinding in testserver
  • Loading branch information
vektah authored Sep 30, 2019
2 parents be5ec0c + 57a3db7 commit 1233330
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 100 deletions.
6 changes: 3 additions & 3 deletions codegen/testserver/complexity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ extend type Query {
}

type OverlappingFields {
oneFoo: Int!
twoFoo: Int!
oldFoo: Int!
oneFoo: Int! @goField(name: "foo")
twoFoo: Int! @goField(name: "foo")
oldFoo: Int! @goField(name: "foo", forceResolver: true)
newFoo: Int!
new_foo: Int!
}
31 changes: 17 additions & 14 deletions codegen/testserver/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 5 additions & 73 deletions codegen/testserver/gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,76 +9,8 @@ resolver:
filename: resolver.go
type: Resolver

models:
It:
model: "github.com/99designs/gqlgen/codegen/testserver/introspection.It"
ModelMethods:
model: "github.com/99designs/gqlgen/codegen/testserver.ModelMethods"
InvalidIdentifier:
model: "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename.InvalidIdentifier"
Changes:
model: "map[string]interface{}"
RecursiveInputSlice:
model: "github.com/99designs/gqlgen/codegen/testserver.RecursiveInputSlice"
Shape:
model: "github.com/99designs/gqlgen/codegen/testserver.Shape"
ShapeUnion:
model: "github.com/99designs/gqlgen/codegen/testserver.ShapeUnion"
Circle:
model: "github.com/99designs/gqlgen/codegen/testserver.Circle"
Rectangle:
model: "github.com/99designs/gqlgen/codegen/testserver.Rectangle"
ForcedResolver:
model: "github.com/99designs/gqlgen/codegen/testserver.ForcedResolver"
fields:
field: { resolver: true }
User:
fields:
friends: { resolver: true }
Error:
model: "github.com/99designs/gqlgen/codegen/testserver.Error"
Errors:
model: "github.com/99designs/gqlgen/codegen/testserver.Errors"
EmbeddedPointer:
model: "github.com/99designs/gqlgen/codegen/testserver.EmbeddedPointerModel"
ThirdParty:
model: "github.com/99designs/gqlgen/codegen/testserver.ThirdParty"
Keywords:
fields:
_: { fieldName: Underscore }
ValidInput:
fields:
_: { fieldName: Underscore }
ValidType:
fields:
different_case: { fieldName: DifferentCaseOld }
Panics:
model: "github.com/99designs/gqlgen/codegen/testserver.Panics"
MarshalPanic:
model: "github.com/99designs/gqlgen/codegen/testserver.MarshalPanic"
Autobind:
model: "github.com/99designs/gqlgen/codegen/testserver.Autobind"
Primitive:
model: "github.com/99designs/gqlgen/codegen/testserver.Primitive"
PrimitiveString:
model: "github.com/99designs/gqlgen/codegen/testserver.PrimitiveString"
MapStringInterfaceInput:
model: "map[string]interface{}"
MapStringInterfaceType:
model: "map[string]interface{}"
OverlappingFields:
model: "github.com/99designs/gqlgen/codegen/testserver.OverlappingFields"
fields:
oneFoo: { fieldName: foo }
twoFoo: { fieldName: foo }
oldFoo: { fieldName: foo, resolver: true }
ObjectDirectivesWithCustomGoModel:
model: "github.com/99designs/gqlgen/codegen/testserver.ObjectDirectivesWithCustomGoModel"
FallbackToStringEncoding:
model: "github.com/99designs/gqlgen/codegen/testserver.FallbackToStringEncoding"
Bytes:
model: "github.com/99designs/gqlgen/codegen/testserver.Bytes"
WrappedStruct:
model: "github.com/99designs/gqlgen/codegen/testserver.WrappedStruct"
WrappedScalar:
model: "github.com/99designs/gqlgen/codegen/testserver.WrappedScalar"
autobind:
- "github.com/99designs/gqlgen/codegen/testserver"
- "github.com/99designs/gqlgen/codegen/testserver/introspection"
- "github.com/99designs/gqlgen/codegen/testserver/invalid-packagename"

2 changes: 1 addition & 1 deletion codegen/testserver/interfaces.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ type Rectangle implements Shape {
width: Float
area: Float
}
union ShapeUnion = Circle | Rectangle
union ShapeUnion @goModel(model:"testserver.ShapeUnion") = Circle | Rectangle

directive @makeNil on FIELD_DEFINITION
4 changes: 2 additions & 2 deletions codegen/testserver/maps.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ extend type Query {
mapNestedStringInterface(in: NestedMapInput): MapStringInterfaceType
}

type MapStringInterfaceType {
type MapStringInterfaceType @goModel(model: "map[string]interface{}") {
a: String
b: Int
}

input MapStringInterfaceInput {
input MapStringInterfaceInput @goModel(model: "map[string]interface{}") {
a: String
b: Int
}
Expand Down
2 changes: 2 additions & 0 deletions codegen/testserver/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@ type PrimitiveString string
func (s PrimitiveString) Doubled() string {
return string(s) + string(s)
}

type Bytes []byte
13 changes: 8 additions & 5 deletions codegen/testserver/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
directive @goModel(model: String, models: [String!]) on OBJECT | INPUT_OBJECT | SCALAR | ENUM | INTERFACE | UNION
directive @goField(forceResolver: Boolean, name: String) on INPUT_FIELD_DEFINITION | FIELD_DEFINITION

type Query {
invalidIdentifier: InvalidIdentifier
collision: It
Expand All @@ -21,7 +24,7 @@ type Subscription {

type User {
id: Int!
friends: [User!]!
friends: [User!]! @goField(forceResolver: true)
created: Time!
updated: Time
}
Expand Down Expand Up @@ -49,7 +52,7 @@ type It {
id: ID!
}

input Changes {
input Changes @goModel(model:"map[string]interface{}") {
a: Int
b: Int
}
Expand All @@ -66,7 +69,7 @@ input OuterInput {
inner: InnerInput!
}

scalar ThirdParty
scalar ThirdParty @goModel(model:"testserver.ThirdParty")

type OuterObject {
inner: InnerObject!
Expand All @@ -77,10 +80,10 @@ type InnerObject {
}

type ForcedResolver {
field: Circle
field: Circle @goField(forceResolver: true)
}

type EmbeddedPointer {
type EmbeddedPointer @goModel(model:"testserver.EmbeddedPointerModel") {
ID: String
Title: String
}
Expand Down
4 changes: 2 additions & 2 deletions codegen/testserver/validtypes.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ extend type Query {
""" These things are all valid, but without care generate invalid go code """
type ValidType {
differentCase: String!
different_case: String!
different_case: String! @goField(name:"DifferentCaseOld")
validInputKeywords(input: ValidInput): Boolean!
validArgs(
break: String!,
Expand Down Expand Up @@ -63,7 +63,7 @@ input ValidInput {
import: String!
return: String!
var: String!
_: String!
_: String! @goField(name: "Underscore")
}

# see https://github.com/99designs/gqlgen/issues/694
Expand Down

0 comments on commit 1233330

Please sign in to comment.