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

Object reference exception: GraphContext.BuildItemQuery<T> #23

Closed jrguth closed 2 years ago

jrguth commented 2 years ago

Schema

https://developer.start.gg/reference/query.doc.html

Test program

using SmashGG.Client;

var context = new QueryContext();

var query = context
    .Player("123")
    .Query;

Console.WriteLine(query.ToString());
Console.ReadLine();

Exception

image

Stack trace

at GraphQLinq.GraphContext.BuildDictionary(Object[] parameterValues, String queryName)\r\n at GraphQLinq.GraphContext.BuildItemQuery[T](Object[] parameterValues, String queryName)\r\n at SmashGG.Client.QueryContext.Player(String id) in C:\repos\SmashGG.Client\SmashGG.Client\QueryContext.cs:line 68 `

Giorgi commented 2 years ago

Can you share sample project?

jrguth commented 2 years ago

SmashGG.Client.zip

Giorgi commented 2 years ago

@jrguth Did you generate the client-side code with GraphQLinq.Scaffolding tool or by the version of that tool from the repo?

jrguth commented 2 years ago

@jrguth Did you generate the client-side code with GraphQLinq.Scaffolding tool or by the version of that tool from the repo?

I had actually pulled the GraphQLinq repo down and ran a slightly modified version of GraphQLinq.Scaffolding locally. This was because an API key header is needed to fetch the schema for this particular service. I had not altered anything other than the one header for the HTTP call

Giorgi commented 2 years ago

The problem is that the code generated by the version of the Scaffolding tool from the latest commit isn't compatible with GraphQLinq.Client NuGet package version. If you use the version from the repository the error won't happen.

Giorgi commented 2 years ago

I updated the client package on NuGet so you shouldn't have this issue if you update the package.