Graphql-dotnet: Identical Object names break schema, no error produced

Created on 19 Sep 2018  路  4Comments  路  Source: graphql-dotnet/graphql-dotnet

Description

If you create InputObjectGraphType and ObjectGraphType with identical names the APi will work but the schema will be invalid.

Steps to reproduce

Create an InputObjectGraphType and ObjectGraphType and set "Name" field to the same string.

Expected result

I would expect and exception, error message, or some other warning

Actual result

API runs happily, but the schema it produces is invalid. The playground doesn't work either.
So, to a random user of the library this is really confusing, because there isn't a good way to figure out what's wrong.

bug

Most helpful comment

This definitely sounds like something that should be fixed. Thanks for the report! I think we do have an issue for something similar, I'll link that if I can find it.

All 4 comments

This definitely sounds like something that should be fixed. Thanks for the report! I think we do have an issue for something similar, I'll link that if I can find it.

Confusing behavior occurs when a name is duplicated between any object or interface graph type. In these cases, the playground works (or at least displays a schema) but the schema only registers the first graph type, silently skipping the rest. Probably this is due to GraphTypesLookup.AddTypeIfNotRegistered. Since the GraphQL spec mandates uniqueness of all type names, maybe this method should throw an exception when it encounters a duplicate name whose type does not match what's already in the lookup dictionary?

Probably solved in #1284

@VladimirAkopyan Can you check if the problem persists?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fiyazbinhasan picture fiyazbinhasan  路  3Comments

mahald picture mahald  路  4Comments

csantero picture csantero  路  4Comments

pravinhabbu4u picture pravinhabbu4u  路  4Comments

dharmeshtailor picture dharmeshtailor  路  4Comments