Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Adding a simple integer enum causes invalid code to be generated #1307

Closed
jwatte opened this issue Aug 25, 2020 · 2 comments
Closed

Adding a simple integer enum causes invalid code to be generated #1307

jwatte opened this issue Aug 25, 2020 · 2 comments
Labels

Comments

@jwatte
Copy link

jwatte commented Aug 25, 2020

What happened?

Start with the default "gqlgen init" project structure.
Add a simple type (here "foo.Mode") to the gql schema and gqlgen.yml
re-generate
get errors:

[18:32:56] jwatte@observe-1804:~/go/src/gqltest$ gqlgen generate
validation failed: packages.Load: /home/jwatte/go/src/gqltest/graph/generated/generated.go:2245:17:     ec.unmarshalInputMode undefined (type *executionContext has no field or method unmarshalInputMode)
/home/jwatte/go/src/gqltest/graph/generated/generated.go:2250:12: ec._Mode undefined (type *executionContext has no field or method _Mode)
/home/jwatte/go/src/gqltest/graph/generated/generated.go:2591:17: ec.unmarshalInputMode undefined (type *executionContext has no field or method unmarshalInputMode)
/home/jwatte/go/src/gqltest/graph/generated/generated.go:2599:12: ec._Mode undefined (type *executionContext has no field or method _Mode)

What did you expect?

I expected appropriate glue for this type to be generated, and no compile errors.

Minimal graphql.schema and models to reproduce

[18:33:04] jwatte@observe-1804:~/go/src/gqltest$ git diff gqlgen.yml graph/schema.graphqls foo/
diff --git a/gqlgen.yml b/gqlgen.yml
index 7c8361f..7feed76 100644
--- a/gqlgen.yml
+++ b/gqlgen.yml
@@ -54,3 +54,5 @@ models:
       - github.com/99designs/gqlgen/graphql.Int
       - github.com/99designs/gqlgen/graphql.Int64
       - github.com/99designs/gqlgen/graphql.Int32
+  Mode:
+    model: github.com/jwatte/go-gqltest/foo.Mode
diff --git a/graph/schema.graphqls b/graph/schema.graphqls
index f6e1bac..a0c3b28 100644
--- a/graph/schema.graphqls
+++ b/graph/schema.graphqls
@@ -7,6 +7,12 @@ type Todo {
   text: String!
   done: Boolean!
   user: User!
+  mode: Mode!
+}
+
+enum Mode {
+  One
+  Two
 }

 type User {
@@ -21,8 +27,9 @@ type Query {
 input NewTodo {
   text: String!
   userId: String!
+  mode: Mode
 }

 type Mutation {
   createTodo(input: NewTodo!): Todo!
-}
\ No newline at end of file
+}


[18:35:44] jwatte@observe-1804:~/go/src/gqltest$ cat foo/mode.go
package foo

type Mode int

const (
        One Mode = 1
        Two Mode = 2
)

versions

  • gqlgen version?

v0.12.2

  • go version?

go version go1.14 linux/amd64

  • dep or go modules?

go mod

@stale
Copy link

stale bot commented Nov 24, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 24, 2020
@danduh
Copy link

danduh commented Nov 12, 2021

@jwatte Have you solved this issue?

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Projects
None yet
Development

No branches or pull requests

2 participants