Giorgi / GraphQLinq

LINQ to GraphQL - Strongly typed GraphQL queries with LINQ query syntax. No more magic strings and runtime errors.
https://www.giorgi.dev/dotnet/introducing-graphqlinq-strongly-typed-graphql-queries-with-linq-to-graphql/
Other
202 stars 21 forks source link

`NullReferenceException` hit on scaffolding #28

Closed SakuraIsayeki closed 2 years ago

SakuraIsayeki commented 2 years ago

During scaffolding, I'm greeted with a NullReferenceException, when attempting to scaffold from my API's GraphQL endpoint.

Exception occurs when trying to scaffold from https://github.com/Nodsoft/SocialGuard/commit/952f76e4f398cb7e6b51647d8796bfb21419ec46 API project, that is using HotChocolate as its GraphQL server infrastructure.

Using the command dotnet graphqlinq-scaffold https://localhost:5011/graphql -n SocialGuard.Client.GraphQL -o Queries, I'm hitting the following stacktrace:

Welcome to GraphQL Client Scaffolding tool

Scaffolding GraphQL client code for https://localhost:5011/graphql to D:\Code\Source\SocialGuard\SocialGuard.Client.GraphQL\Queries
Running introspection query ...
Reading and deserializing schema information ...

Unhandled exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at GraphQLinq.Scaffolding.GraphQLClassesGenerator.GenerateClient(Schema schema, String endpointUrl)
   at GraphQLinq.Scaffolding.Program.<>c__DisplayClass2_0.<HandleGenerate>b__0(StatusContext statusContext) in d:\src\GraphQLinq\src\GraphQLinq.Scaffolding\Program.cs:line 161
   at Spectre.Console.Status.<>c__DisplayClass15_0`1.<Start>b__0(StatusContext ctx) in /_/src/Spectre.Console/Widgets/Progress/Status.cs:line 63
   at Spectre.Console.Status.<>c__DisplayClass17_0`1.<<StartAsync>b__0>d.MoveNext() in /_/src/Spectre.Console/Widgets/Progress/Status.cs:line 123
--- End of stack trace from previous location ---
   at Spectre.Console.Progress.StartAsync[T](Func`2 action) in /_/src/Spectre.Console/Widgets/Progress/Progress.cs:line 136
   at Spectre.Console.Status.StartAsync[T](String status, Func`2 func) in /_/src/Spectre.Console/Widgets/Progress/Status.cs:line 120
   at Spectre.Console.Status.Start[T](String status, Func`2 func) in /_/src/Spectre.Console/Widgets/Progress/Status.cs:line 64
   at GraphQLinq.Scaffolding.Program.HandleGenerate(Uri endpoint, String output, String namespace, String context, IConsole console) in d:\src\GraphQLinq\src\GraphQLinq.Scaffolding\Program.cs:line 150
   at System.CommandLine.Invocation.CommandHandler.GetResultCodeAsync(Object value, InvocationContext context)
   at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseErrorReporting>b__21_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass25_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__22_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseParseDirective>b__20_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseDebugDirective>b__11_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseExceptionHandler>b__0>d.MoveNext()
Giorgi commented 2 years ago

Can you run Introspection Query against the endpoint and attach the output to the issue?

SakuraIsayeki commented 2 years ago

Good morning Giorgi, Here it is, introspection query as requested : https://gist.github.com/SakuraIsayeki/2fd29f0089f078fa72ba8d145506fbe8

Giorgi commented 2 years ago

@SakuraIsayeki I think this is already fixed in the latest version of the repo. Can you clone the repo and run the scaffolding application directly?

Giorgi commented 2 years ago

I updated the scaffolding tool on NuGet so you shouldn't have this issue if you run the updated version of the tool.