-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
(outdated samples?) This graph type 'OutputObjectGraphType<Book>' with name 'Book' has already been initialized. #237
Comments
I can confirm that GraphQL.NET 7.2.0 does not work with the conventions sample project. I can't figure out why. For some reason
It seems that while registering the Book type, the Author type gets registered as a field of the Book type, and then when it goes to add the Author type (as all types are registered via I've checked the DI implementation; it's not that. The code certainly creates two different copies during initialization and using them within the schema. |
It seems that the SubscriptionExample is working. I've updated it for GraphQL.NET 7.2.0 in the following PR: Sorry, I'm not sure why the other sample isn't working. Maybe @tlil can provide some insight. |
You are correct that graphql-dotnet/graphql-dotnet#3332 is the cause of the errors you are getting. The validation was added to ensure that two instances of the same type are not registered to the same schema. If that were to happen, proper initialization and validation of one of the two instances may not occur. While I'm not sure exactly how/if that were to affect this library, we want to preserve enforcement of the check in the main GraphQL.NET project. It is possible to clone an older copy of The best way to permanently solve this issue is to reduce the sample to the minimum code/schema required to reproduce the issue. You can test for the issue easier by adding If you can identify the cause (for example perhaps it's due to a Union or Interface type in use), you may even be able to reduce the scope further into a test. The simpler the issue, the easier it will be to solve. |
I have a suspicion of what's going on here. Thanks for flagging. Out travelling at the moment, but will take a look when I'm back on Sunday. |
Any update @tlil ? |
Been out sick, sorry. Found the issue and will try and get a fix out by early next week. |
As discovered in #237, and after the addition of integrity checks in the parent library (graphql-dotnet/graphql-dotnet#3332), the Convention library has been shown to create duplicate instances of derived graph types in some cases due to insufficient caching logic. Previously, this didn't flag since there were no integrity checks to look for this kind of behaviour. The types are derived deterministically, so although this miss caused usage with the latest version of the library to bark on query execution, there should be no logical changes in the way schemas are derived and evaluated (bar not triggering an error, obviously!) with this change.
@Shane32 see:
It offers a fix to the issue outlined above. Looking at this (now old) code, there's a few things I'd like to do to tidy up the logic. However, I'll save that for subsequent PRs. :-) |
Hey all,
I'm in the proces of upgrading to GQL v7 and I need a little bit of help.
We have a fairly big schema and it also contains some unions. So I was waiting for the issue described in #234 to be fixed. After upgrading to v7.2 our tests are failing and I'm getting other issues now.
So, after trying to fix this for an hour, I decided to build the SimpleWebApp from the samples.
When using GraphQL.NET 7.1.1 or later I'm getting this on the first execution:
"message": "Error executing document. A different instance of the GraphType 'OutputObjectGraphType<Author>' with the name 'Author' has already been registered within the schema. Please use the same instance for all references within the schema, or use GraphQLTypeReference to reference a type instantiated elsewhere.",
And this when I execute my query another time:
"message": "Error executing document. This graph type 'OutputObjectGraphType<Book>' with name 'Book' has already been initialized. Make sure that you do not use the same instance of a graph type in multiple schemas. It may be so if you registered this graph type as singleton; see https://graphql-dotnet.github.io/docs/getting-started/dependency-injection/ for more info.",
The change log for GraphQL.NET 7.1.1 is showing me this issue I'm experiencing: graphql-dotnet/graphql-dotnet@7.1.0...7.1.1
Might this be another issue in the GraphQL.NET project or am I just totally missing something in the migration documentation?
The text was updated successfully, but these errors were encountered: