Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Use autobinding in testserver #882

Merged
merged 1 commit into from
Sep 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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