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
v0.12.1 crashes inside gotpl where v0.11.3 gives error messages #1293
Comments
I faced the issue when upgrading to v0.12.2 from v0.11.3. I guess it's a bug that assume Nilable Marshaler will have Elem at the same time. The following patch can work around, but I',m not sure any other edge cases will happen. {{- else if eq ($type.GO | ref) "map[string]interface{}" }}
return v.(map[string]interface{}), nil
{{- else if $type.IsMarshaler }}
- {{- if $type.IsNilable }}
+ {{- if and $type.IsNilable $type.Elem }}
var res = new({{ $type.Elem.GO | ref }})
{{- else}}
var res {{ $type.GO | ref }}
{{- end }}
err := res.UnmarshalGQL(v)
return res, graphql.WrapErrorWithInputPath(ctx, err) |
For what it's worth this was introduced in 997efd0 |
With 0.12.2, we now crash even on seemingly legitimate schemas (that work well in 11.3) so we have to pin version 11.3. |
I think fredbi's problem is the same as mine -- I also have a scalar type that's map[string]interface{} |
Easily reproducible with a scalar like:
Are there any plans to fix this in the near future? |
Running into the same problem with a v0.13.0 |
For anyone looking for a temporary solution, doing something like this is enough to bypass it:
|
How does this bypass the problem? It's a generation problem, right? |
@minitauros It's working around the problem by replacing the It appears GQLGen gives preference to the function format, so you can simply call the original method as a work-around, and remove it when this bug is fixed. func MarshalScalarType(t ScalarType) graphql.Marshaler {
return graphql.WriterFunc(t.MarshalGQL)
}
func UnmarshalScalarType(v interface{}) (t ScalarType, err error) {
err = t.UnmarshalGQL(v)
return
} |
I tried @duckbrain workaround, but it doesn't work on v0.13.0. I have a type:
Running gqlgen, I get this error:
The generated callers are:
If I update the implementation of marshal/unmarshal, I instead get these errors:
The erroring lines are:
So, I'm now in a catch-22 -- with a pointer implementation, some functions fail; with a value implementation, some other functions fail. And removing the function implementation, falling back to the interface, still provokes the bad code path, which causes gqlgen to error out with a bad template:
|
@jwatte You can change it to |
We tried the fix proposed by @oiime and @duckbrain above and it didn't work. There has been a PR up for this for quite a while (see #1317); I have poked one of the maintainers to see if it can be merged sooner rather than later. |
i also tries byt above hack didn't work |
I'm running gqlgen on a schema that has some errors.
v0.12.1 gives a very unhelpful error message:
v0.11.3 is more helpful:
I expect gqlgen to not crash with an error message that tells me nothing about where the cause for the error is, instead I expect it to give me good error messages.
(I think 0.11.3 actually generated the code and the errors come from the go compile command, so maybe this reduces to "v0.12.1 shouldn't crash, period!")
Attaching schema.graphql and gqlgen.yml files
The text was updated successfully, but these errors were encountered: