I am following this strawberry shake tutorial in C# console app. All the steps are successfully performed but when I tried to build using dotnet build , it is getting failed with the below error:
EXEC : error GQL: An item with the same key has already been added. Key: JSON [D:\HTH\GraphQL\StrawberryShake_Graphql_client\GraphqlStrawberry\GraphqlStrawberry\GraphqlStrawberry.csproj] C:\Users\Faizan Khan.nuget\packages\strawberryshake.server\13.0.5\build\StrawberryShake.Server.targets(63,5): error MSB3073: The command "dotnet "C:\Users\Faizan Khan.nuget\packages\strawberry shake.server\13.0.5\build..\tools\net6\dotnet-graphql.dll" generate "D:\HTH\GraphQL\StrawberryShake_Graphql_client\GraphqlStrawberry\GraphqlStrawberry" -o "D:\HTH\GraphQL\StrawberryShake_Graphq l_client\GraphqlStrawberry\GraphqlStrawberry\obj\Debug\net6.0\berry" -n GraphqlStrawberry -a md5 -t" exited with code 1. [D:\HTH\GraphQL\StrawberryShake_Graphql_client\GraphqlStrawberry\GraphqlS trawberry\GraphqlStrawberry.csproj]
Build FAILED.
EXEC : error GQL: An item with the same key has already been added. Key: JSON [D:\HTH\GraphQL\StrawberryShake_Graphql_client\GraphqlStrawberry\GraphqlStrawberry\GraphqlStrawberry.csproj] C:\Users\Faizan Khan.nuget\packages\strawberryshake.server\13.0.5\build\StrawberryShake.Server.targets(63,5): error MSB3073: The command "dotnet "C:\Users\Faizan Khan.nuget\packages\strawberry shake.server\13.0.5\build..\tools\net6\dotnet-graphql.dll" generate "D:\HTH\GraphQL\StrawberryShake_Graphql_client\GraphqlStrawberry\GraphqlStrawberry" -o "D:\HTH\GraphQL\StrawberryShake_Graphq l_client\GraphqlStrawberry\GraphqlStrawberry\obj\Debug\net6.0\berry" -n GraphqlStrawberry -a md5 -t" exited with code 1. [D:\HTH\GraphQL\StrawberryShake_Graphql_client\GraphqlStrawberry\GraphqlS trawberry\GraphqlStrawberry.csproj] 0 Warning(s) 2 Error(s)
Here are the steps which i have taken before building the project
The underlying issue is related to the .graphqlrc.json configuration file being too open (due to the "any directory" value) once the generated files are created.
What worked for me was to create a sub-directory and place all of the source query files in there.
To give a specific example, I added a "[project root]/client_queries" directory and moved all of the *.graphql query files into this directory.
I then changed the following value for the "documents" element in the .graphqlrc.json configuration file from:
{
"schema": "schema.graphql",
"documents": "**\*.graphql", <-- CHANGED THIS
"extensions": {
"strawberryShake": {
"name": "StrawberryClient",
"url": "https://example.com/graphql"
}
}
}
to the specific directory that holds the source query files:
{
"schema": "schema.graphql",
"documents": "client_queries\*.graphql", <-- TO THIS
"extensions": {
"strawberryShake": {
"name": "StrawberryClient",
"url": "https://example.com/graphql"
}
}
}
I rebuilt the solution and this appears to have resolved the referenced error for me. Hopefully this is helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With