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

[proposal] Optional pointer return in unmarshalInput #2384

Closed
LuciferInLove opened this issue Sep 17, 2022 · 0 comments
Closed

[proposal] Optional pointer return in unmarshalInput #2384

LuciferInLove opened this issue Sep 17, 2022 · 0 comments

Comments

@LuciferInLove
Copy link
Contributor

What happened?

It'd be nice to have an option to return a pointer instead of a value in unmarshalInput:
https://github.com/99designs/gqlgen/blob/master/codegen/input.gotpl#L3

What did you expect?

I'd expect something like:
codegen/input.gotpl

func (ec *executionContext) unmarshalInput{{ .Name }}(ctx context.Context, obj interface{}) ({{ if returnPointerInUnmarshalInput }}*{{ end }}{{.Type | ref}}, error) {
...
return {{ if returnPointerInUnmarshalInput }}&{{ end }}it, nil

And related changes in codegen/type.gotpl.
https://github.com/99designs/gqlgen/blob/master/codegen/type.gotpl#L78

Minimal graphql.schema and models to reproduce

versions

  • go run github.com/99designs/gqlgen version? v0.17.16
  • go version? go1.18.6
@LuciferInLove LuciferInLove changed the title Optional pointer return in unmarshalInput [proposal] Optional pointer return in unmarshalInput Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant