Skip to content
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

StrawberryShake code generation crashes if directive specifies location VARIABLE_DEFINITION #7025

Open
nloum opened this issue Mar 27, 2024 · 0 comments
Labels

Comments

@nloum
Copy link
Contributor

nloum commented Mar 27, 2024

Product

Strawberry Shake

Version

13.9.0 and also 14.0.0-p.80

Link to minimal reproduction

https://github.com/nloum/Repro-StrawberryShakeVariableDefinitionLocation

Steps to reproduce

Add a directive to your schema like this:

directive @aRandomDirective on VARIABLE_DEFINITION

The important part is specifying VARIABLE_DEFINITION.

What is expected?

The project should compile successfully.

What is actually happening?

The project fails to compile

Relevant log output

PS C:\src\Repro-StrawberryShakeVariableDefinitionLocation> dotnet build
MSBuild version 17.9.6+a4ecab324 for .NET
  Determining projects to restore...
  Restored C:\src\Repro-StrawberryShakeVariableDefinitionLocation\Repro-StrawberryShakeVariableDefinitionLocation.csproj (in 273 ms).
  Generate C# Clients started.
  Generate MyAppClient started.
  Generate MyAppClient completed in 76 ms
  Generate C# Clients completed in 182 ms
  Unhandled exception. System.AggregateException: One or more errors occurred. (The specified location `VARIABLE_DEFINITION` is not supported.)
   ---> System.NotSupportedException: The specified location `VARIABLE_DEFINITION` is not supported.
     at HotChocolate.Types.Factories.DirectiveTypeFactory.MapDirectiveLocation(DirectiveLocation location) in /home/runner/work/graphql-platform/graphql-platfor 
  m/src/HotChocolate/Core/src/Types/Types/Factories/DirectiveTypeFactory.cs:line 164
     at HotChocolate.Types.Factories.DirectiveTypeFactory.DeclareLocations(DirectiveTypeDefinition parent, DirectiveDefinitionNode node) in /home/runner/work/gr 
  aphql-platform/graphql-platform/src/HotChocolate/Core/src/Types/Types/Factories/DirectiveTypeFactory.cs:line 154
     at HotChocolate.Types.Factories.DirectiveTypeFactory.Create(IDescriptorContext context, DirectiveDefinitionNode node) in /home/runner/work/graphql-platform 
  /graphql-platform/src/HotChocolate/Core/src/Types/Types/Factories/DirectiveTypeFactory.cs:line 112
     at HotChocolate.Types.Factories.SchemaSyntaxVisitor.VisitChildren(DirectiveDefinitionNode node, SchemaSyntaxVisitorContext context) in /home/runner/work/gr 
  aphql-platform/graphql-platform/src/HotChocolate/Core/src/Types/Types/Factories/SchemaSyntaxVisitor.cs:line 161
     at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ISyntaxNode node, TContext context) in /home/runner/work/graphql-platform/graphql-platform/ 
  src/HotChocolate/Language/src/Language.Visitors/SyntaxVisitor~1.VisitationMap.cs:line 78
     at HotChocolate.Language.Visitors.SyntaxVisitor`1.Visit[TNode,TParent](TNode node, TParent parent, TContext context) in /home/runner/work/graphql-platform/ 
  graphql-platform/src/HotChocolate/Language/src/Language.Visitors/SyntaxVisitor~1.cs:line 76
     at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(DocumentNode node, TContext context) in /home/runner/work/graphql-platform/graphql-platform 
  /src/HotChocolate/Language/src/Language.Visitors/SyntaxVisitor~1.VisitationMap.cs:line 107
     at HotChocolate.Language.Visitors.SyntaxVisitor`1.VisitChildren(ISyntaxNode node, TContext context) in /home/runner/work/graphql-platform/graphql-platform/ 
  src/HotChocolate/Language/src/Language.Visitors/SyntaxVisitor~1.VisitationMap.cs:line 40
     at HotChocolate.Language.Visitors.SyntaxVisitor`1.Visit[TNode,TParent](TNode node, TParent parent, TContext context) in /home/runner/work/graphql-platform/ 
  graphql-platform/src/HotChocolate/Language/src/Language.Visitors/SyntaxVisitor~1.cs:line 76
     at HotChocolate.Language.Visitors.SyntaxVisitor`1.Visit(ISyntaxNode node, TContext context) in /home/runner/work/graphql-platform/graphql-platform/src/HotC 
  hocolate/Language/src/Language.Visitors/SyntaxVisitor~1.cs:line 61
     at HotChocolate.SchemaBuilder.Setup.ParseDocuments(SchemaBuilder builder, IDescriptorContext context) in /home/runner/work/graphql-platform/graphql-platfor 
  m/src/HotChocolate/Core/src/Types/SchemaBuilder.Setup.cs:line 143
     at HotChocolate.SchemaBuilder.Setup.CreateTypeReferences(SchemaBuilder builder, IDescriptorContext context) in /home/runner/work/graphql-platform/graphql-p 
  latform/src/HotChocolate/Core/src/Types/SchemaBuilder.Setup.cs:line 116
     at HotChocolate.SchemaBuilder.Setup.Create(SchemaBuilder builder, LazySchema lazySchema, IDescriptorContext context) in /home/runner/work/graphql-platform/ 
  graphql-platform/src/HotChocolate/Core/src/Types/SchemaBuilder.Setup.cs:line 68
     at HotChocolate.SchemaBuilder.Setup.Create(SchemaBuilder builder) in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Core/src/Types/Sc 
  hemaBuilder.Setup.cs:line 28
     at HotChocolate.SchemaBuilder.Create() in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Core/src/Types/SchemaBuilder.Create.cs:line  
  10
     at HotChocolate.SchemaBuilder.HotChocolate.ISchemaBuilder.Create() in /home/runner/work/graphql-platform/graphql-platform/src/HotChocolate/Core/src/Types/S 
  chemaBuilder.Create.cs:line 29
     at StrawberryShake.CodeGeneration.Utilities.SchemaHelper.Load(IReadOnlyCollection`1 schemaFiles, Boolean strictValidation, Boolean noStore) in /home/runner 
  /work/graphql-platform/graphql-platform/src/StrawberryShake/CodeGeneration/src/CodeGeneration/Utilities/SchemaHelper.cs:line 92
     at StrawberryShake.CodeGeneration.CSharp.CSharpGenerator.TryCreateSchema(IReadOnlyList`1 files, Dictionary`2 fileLookup, ICollection`1 errors, Boolean stri 
  ctValidation, Boolean noStore, ISchema& schema) in /home/runner/work/graphql-platform/graphql-platform/src/StrawberryShake/CodeGeneration/src/CodeGeneration.C 
  Sharp/CSharpGenerator.cs:line 424
     at StrawberryShake.CodeGeneration.CSharp.CSharpGenerator.GenerateAsync(IEnumerable`1 fileNames, CSharpGeneratorSettings settings) in /home/runner/work/grap 
  hql-platform/graphql-platform/src/StrawberryShake/CodeGeneration/src/CodeGeneration.CSharp/CSharpGenerator.cs:line 101
     --- End of inner exception stack trace ---
     at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
     at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
     at StrawberryShake.Tools.GenerateCommand.GenerateCommandHandler.GenerateClient(String clientName, String[] documents, CSharpGeneratorSettings settings) in  
  /home/runner/work/graphql-platform/graphql-platform/src/StrawberryShake/Tooling/src/dotnet-graphql/GenerateCommand.cs:line 164
     at StrawberryShake.Tools.GenerateCommand.GenerateCommandHandler.ExecuteAsync(GenerateCommandArguments args, CancellationToken cancellationToken) in /home/r 
  unner/work/graphql-platform/graphql-platform/src/StrawberryShake/Tooling/src/dotnet-graphql/GenerateCommand.cs:line 124
     at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
     at StrawberryShake.Tools.Program.<Main>(String[] args)
C:\Users\nloum\.nuget\packages\strawberryshake.server\13.9.0\build\StrawberryShake.Server.targets(83,5): error MSB3073: The command "dotnet "C:\User
s\nloum\.nuget\packages\strawberryshake.server\13.9.0\build\..\tools\net8\dotnet-graphql.dll" generate "C:\src\Repro-StrawberryShakeVariableDefiniti
onLocation" -o "C:\src\Repro-StrawberryShakeVariableDefinitionLocation\obj\Debug\net8.0\berry" -n Repro_StrawberryShakeVariableDefinitionLocation -a md5 -t" exi 
ted with code -532462766. [C:\src\Repro-StrawberryShakeVariableDefinitionLocation\Repro-StrawberryShakeVariableDefinitionLocation.csproj]

Build FAILED.

C:\Users\nloum\.nuget\packages\strawberryshake.server\13.9.0\build\StrawberryShake.Server.targets(83,5): error MSB3073: The command "dotnet "C:\User
s\nloum\.nuget\packages\strawberryshake.server\13.9.0\build\..\tools\net8\dotnet-graphql.dll" generate "C:\src\Repro-StrawberryShakeVariableDefiniti
onLocation" -o "C:\src\Repro-StrawberryShakeVariableDefinitionLocation\obj\Debug\net8.0\berry" -n Repro_StrawberryShakeVariableDefinitionLocation -a md5 -t" exi
ted with code -532462766. [C:\src\Repro-StrawberryShakeVariableDefinitionLocation\Repro-StrawberryShakeVariableDefinitionLocation.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:02.60

Workload updates are available. Run `dotnet workload list` for more information.
PS C:\src\Repro-StrawberryShakeVariableDefinitionLocation>

Additional context

Directives with VARIABLE_DEFINITION as their location can be generated by a HotChocolate server, so I would expect StrawberryShake to support that. Also, the schema parses successfully when using HotChocolate.Language.Utf8GraphQLParser.

The reason I'm using this custom directive is because I'm doing automated analysis my GraphQL queries, so I don't want StrawberryShake's generated code to be different based on my custom directive.

@nloum nloum added the 🐛 bug Something isn't working label Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants