Closed niles11 closed 11 months ago
This is a very serious issue which is easily reproduced on any schema having the definition of scalar JSON.
I have managed to make the reproducing example even for the Hotchocolate server.
Suppose we have the very basic schema:
schema {
query: Query
}
type Query {
persons: [Person!]!
}
type Person {
data: JSON
}
scalar JSON
Or in terms of code first:
namespace Demo.Server;
public class Person
{
public System.Text.Json.JsonElement? Data { get; set; }
}
public class Query
{
public ICollection<Person> GetPersons() => Array.Empty<Person>();
}
public class QueryType : ObjectType<Query> { }
Then any attempt of generating the client (whether with dotnet build or with dotnet graphql generate ) causes the error "EXEC : error GQL: An item with the same key has already been added. Key: JSON"
I have prepared the solution with the full reproducing of the issue and attached here strawberryshake-6257.zip
Once the problem is incorrect processing of 'scalar JSON' in the schema the workaround is to remove (or comment out) in schema.graphql the scalar JSON. In that case, the client will be generated successfully but those fields that are of JSON type will have the type 'string' instead of JsonDocument/JsonElement.
I encountered the same issue. Is there any patch scheduled?
Same issue. After reading the encouraging What's New in v13 about JSON - https://chillicream.com/blog/2023/02/08/new-in-hot-chocolate-13#json-scalar tried to engage in our project. Alas...
Any news on this? I cannot use the client as it is right now.
It seems this is fixed since v13.8.0, which has been released yesterday. This exact issue is not resolved or mentioned in the releasenotes so I only noticed the change by coincidence. The releasenotes do mention these two fixes:
I have checked and I can verify that this solves my original issue 🥳
Is there an existing issue for this?
Product
Strawberry Shake
Describe the bug
Hi, i'm using StrawberryShake to connect to a ContentStack GraphQL interface. ContentStack is a CMS, which means you can add content models in the CMS and after doing that the schema will automatically update accordingly. The StrawberryShake experience so far has been good, even with man, many different content models which all have nested fields.
However, recently I started using a field type that we had not used before in any content model: the JSON RTE field. This field accepts markdown text but it will be converted into json. After running the command
dotnet graphql update ...
and doing a rebuild of the solution I get the following error:An item with the same key has already been added. Key: JSON
I do see these changes in the schema.graphql file:
The changes seem to suggest there is support for 'raw' json within the graphql response. But the solution no longer compiles because of the error mentioned above. It should not be related to this StackOverflow issue, because without the JSON RTE field in the content model StrawberryShake immediately works perfectly fine.
Steps to reproduce
Relevant log output
Additional Context?
No response
Version
13.2.0