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

Codegen broken since v0.12 using external map scalar types #1391

Closed
fredbi opened this issue Nov 12, 2020 · 2 comments
Closed

Codegen broken since v0.12 using external map scalar types #1391

fredbi opened this issue Nov 12, 2020 · 2 comments

Comments

@fredbi
Copy link

fredbi commented Nov 12, 2020

What happened?

  • I have a schema with imported scalar types.
  • works fine with gqlgen =< v0.11.3
  • breaks start with v0.12:
codegen: generating core failed: type.gotpl: template: type.gotpl:49:28: executing "type.gotpl" at <$type.Elem.GO>: nil pointer evaluating *config.TypeReference.GO

The faulty template code in codegen/type.gotpl is:

@@ -46,7 +46,21 @@
                                        return v.(map[string]interface{}), nil
                                {{- else if $type.IsMarshaler }}
                                        {{- if $type.IsNilable }}
-                                               var res = new({{ $type.Elem.GO | ref }})

Investigating further, the template fails when looping over my scalar types.

In my case, scalar types are maps, e.g. map[string]interface{}, map[string]string, map[string]float64.
This hits the case of a nullable type with no (known) element type (there is one, but it is not introspected, as only slices are introspected for the type of their element).

What did you expect?

Successful codegen

Minimal graphql.schema and models to reproduce

(TODO)

versions

  • gqlgen version? v0.12.x, v0.13.0, current master
  • go version? 1.15.3
  • dep or go modules? go modules
fredbi added a commit to fredbi/gqlgen that referenced this issue Nov 12, 2020
…nts (e.g. external scalar type)

* fixes 99designs#1391

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
fredbi added a commit to fredbi/gqlgen that referenced this issue Nov 12, 2020
…nts (e.g. external scalar type)

* fixes 99designs#1391

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@fredbi fredbi changed the title Codegen broken since v0.12 using external scalar types Codegen broken since v0.12 using external map scalar types Nov 12, 2020
@fredbi
Copy link
Author

fredbi commented Nov 12, 2020

Maybe a duplicate (or at least a special case) of #1293

@frederikhors
Copy link
Collaborator

@fredbi please tell me if this is still an issue and I'll re-open it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants