Skip to content

Commit

Permalink
Added a model and used directive on an input field within the integra…
Browse files Browse the repository at this point in the history
…tion schema

Added to the integration schema such that the build will catch the directive bug in question.
  • Loading branch information
enjoylife committed Feb 10, 2019
1 parent 0b0e4a9 commit a2e61b3
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 0 deletions.
46 changes: 46 additions & 0 deletions codegen/testserver/generated.go

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

2 changes: 2 additions & 0 deletions codegen/testserver/gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ models:
model: "github.com/99designs/gqlgen/codegen/testserver.Error"
EmbeddedPointer:
model: "github.com/99designs/gqlgen/codegen/testserver.EmbeddedPointerModel"
ThirdParty:
model: "github.com/99designs/gqlgen/codegen/testserver.ThirdParty"
1 change: 1 addition & 0 deletions codegen/testserver/models-gen.go

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

3 changes: 3 additions & 0 deletions codegen/testserver/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ input OuterInput {
inner: InnerInput!
}

scalar ThirdParty

input InputDirectives {
text: String! @length(min: 0, max: 7, message: "not valid")
inner: InnerDirectives!
innerNullable: InnerDirectives
thirdParty: ThirdParty @length(min: 0, max: 7, message: "not valid")
}

input InnerDirectives {
Expand Down
30 changes: 30 additions & 0 deletions codegen/testserver/thirdparty.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package testserver

import (
"fmt"
"github.com/99designs/gqlgen/graphql"
"io"
"strconv"
)

type ThirdParty struct {
str string
}

func MarshalThirdParty(tp ThirdParty) graphql.Marshaler {
return graphql.WriterFunc(func(w io.Writer) {
_, err := io.WriteString(w, strconv.Quote(tp.str))
if err != nil {
panic(err)
}
})
}

func UnmarshalThirdParty(input interface{}) (ThirdParty, error) {
switch input := input.(type) {
case string:
return ThirdParty{str: input}, nil
default:
return ThirdParty{}, fmt.Errorf("unknown type for input: %s", input)
}
}

0 comments on commit a2e61b3

Please sign in to comment.