question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Schema with unions throws NullReferenceException

See original GitHub issue

Hi! Looks like it is currently not possible to generate a client from a schema that contains Union types. In Snowflaqe we get a Object reference not set to an instance of an object, but we (@margaretkrutikova and @danielstarck) tracked it down to the following line in graphql-dotnet. The problem is that when called like this, both union.ResolveType and union.IsTypeOf are null.

Not sure if we should open an issue there, since it’s not entirely clear to me whether the way it is called from Snowflaqe is the intended usage. The examples in graphql-dotnet docs provide the actual types when calling Schema.For, while Snowflaqe only provides the shcema string. Please advice.

I’ve opened a PR with a simple repro here: https://github.com/Zaid-Ajaj/Snowflaqe/pull/69

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Zaid-Ajajcommented, May 28, 2022

@MargaretKrutikova thanks a lot for digging into this! It saves me a lot of time debugging 🙏 I understand the problem better now and the fix looks great to me, if you include it in the PR #69, I would be happy to merge and publish a new version of Snowflaqe

1reaction
Yakimychcommented, May 26, 2022

Hi @Zaid-Ajaj, and thanks for the quick reply! Unfortunately it might not be a regression (at least not in the latest version), as I’ve tried both 1.36.0 as well as 1.34.0, and both return the same error message.

I’ve tried running both versions against a JSON-schema as you suggested, and both work smoothly. Not sure if it helps though, since the operation that fails is the one that is trying to convert the SDL to JSON itself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Schema resolution incorrectly failing for union with null and ...
Demonstrated with a producer using schema_1 which is a record type containing a union field of null and another record. A consumer attempts...
Read more >
Avro Schema. How to set type to "record" and "null" at once
1 Answer 1 · But now I am getting "Not in union" exception while adding record, can you help. – Nadir Novruzov. Apr...
Read more >
Avro schema - optional fields - gives "Not in Union" exception
Hi all,I have a problem with using optional fields in an avro schema and using the JSONAvroBinding.If I have a User schema that...
Read more >
AvroType operators can create nested unions
AvroType operators can create nested unions ... this (already union) type and create a nested union which throws an AvroRuntimeException.
Read more >
Avro: unions & default values - ‍Federico Ragona
I recently spent a few hours scratching my head trying to understand Avro's default values (in particular, when combined with unions), ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found