Closed ktomanelli closed 1 year ago
It is bootstrapped via source-generated code like that:
It looks like something is wrong with your source generator setup.
@ktomanelli Have you managed to figure out what was wrong?
Not yet, diving back into this now. So the dictionary is set upon code generation, as in when running the dotnet zeroql generate
cli command correct? So if I'm getting this error it means something went wrong during generation?
I started a new project and followed the instructions in the readme and am also getting this same error. Here is a link to the repo
So the dictionary is set upon code generation, as in when running the dotnet zeroql generate cli command correct No. The dotnet zeroql generate cli creates classes for GraphQL client and it is done here. Then when you write something like that
var result = awair client.Query(static q => q.Me(o => o.FirstName));
The source analyzer inside the IDE will find
Query(static q => q.Me(o => o.FirstName));
, convert it into the graphql query, generates code to set up the dictionary. All of it happens in the background while you are typing.
What IDE do you use?
currently using Visual studio for mac
It works fine in VS for Mac 17.3.8 for me. What version do you use?
Does it happen when you run the app via CLI?
dotnet run
Okay so I now have the repo i sent with your example getting past the bootstrap error and hitting the endpoint which doesnt exist on my end, so different error but thats good! However once I replace the dummy schema with a real one from my hotchocolate server and adjust the query to retrieve actual data, I'm once again getting that bootstrap error.
Does it happen when you run the app via CLI?
dotnet run
System.InvalidOperationException: Query is not bootstrapped.
at ZeroQL.GraphQLClient2.Execute[TVariables,TOperationType,TResult](TVariables variables, Func
3 queryMapper, String queryKey)
at GraphQLClientRequestExtensions.Execute[TQuery,TResult](IGraphQLClient client, GraphQL`2 request)
at Program.
In this case, I have no idea what could go wrong, except something bad happened with your local dotnet setup.
@ktomanelli, here is the thread for a very simular issue. https://youtrack.jetbrains.com/issue/RIDER-82960/Source-Generator-Code-is-not-getting-recognised
They managed to fix it by installing .net 6.0.401
I'm also having this issue except i'm using the lambda syntax, I'm attempting this on Windows using ZeroQL 3.1.0.
I've installed each version of the .net 6 sdk after and including 6.0.401 one at a time, restarted Visual Studio & Visual Studio Code after each install and it's still not working. I've even restarted my machine after each attempt.
An update to the lastest version of Visual Studio (17.4.3 at the time of writing) also didn't fix the problem.
UPDATE
After trial and error throughout the day, I decided to change my "lambda" syntax to "request" syntax against ZeroQL 3.1.0 and that is now working.
Has there been an issue introduced into the lambda syntax since 3.1.0 was released?
When you hover over the Query
method, can you see the graphql preview?
https://user-images.githubusercontent.com/5927686/207651514-3a9733ec-0841-40fb-ac0a-a1135ba42841.mov
Yes, using lambda syntax i can hover over the _client.Query
and it gives me the full graphql preview that i would expect (it is fully correct)
it builds and runs fine, but when it comes to execute the query it throws the "Query is not Bootstrapped" exception, but to reiterate, this is just the lambda syntax - I have just now had a successful execution using the request syntax
Has there been an issue introduced into the lambda syntax since 3.1.0 was released?
I don't think so. It is difficult to say because it has been working fine for me and at least 5+ people I know personally. However, in version 3.2.0-preview.2, there is a change in lambda syntax detection. You can try this version.
Can you try to run and send output here
dotnet build -v diag > out.txt
Maybe there will be something interesting.
@be1223 Have you been using ZeroQL before 3.1.0?
Before v2.0.0-preview.6 to be precise.
@byme8 Not sure what the problem was, but lambda syntax is now also working for me in the same project, chances are i had some error in the syntax.
Regardless, lambda and request syntax are both working for me now!
I too am having this issue intermittently... I have a test repo up at https://github.com/gaffo/CSharpHotChocolateZeroQLIntegrationTestExample with a branch at ZQL-21 on 3.2.0-preview.4 ... but it seems to be a non-deterministic bug. Just changing versions and regenerating seemed to have made it work... There was even a run where one of the mutations was failing but the exact same mutation on a different unit test that ran in the same run worked.
I managed to reproduce a similar issue with 3.2.0-preview.3. It happened because of Microsoft.CodeAnalysis.CSharp NuGet package 4.4.0. As far as I understood, it was too new. To use it, you need to have the latest dotnet SDK installed.
In 3.2.0-preview.4 I downgraded Microsoft.CodeAnalysis.CSharp to version 4.0.0(year old version), and now it works as expected.
@be1223 @ktomanelli Can you try the version 3.2.0-preview.4?
@gaffo To clarify. you got an error, changed the version to 3.2.0-preview.4 and now it works as expected?
Actually I had to run the tests multiple times with 3.2.0-preview.4 and after a few runs all of them passed without me changing any code. I'm not sure if there was an incremental compile going on in rider or what... One of the mutation tests failed (you can look at them and see they're almost identical) while the other passed, the failure was due to the bootstrapped error.
I tried to be scientific but the fix seemed to be "change versions up and down and recompile several times and maybe it goes away" which is not really a satisfactory answer for those hitting this issue or for seeing why it's happening. Sorry I haven't been able to re-reproduce it.
I can try and downgrade back to 3.2.0-preview.2 and see if it fails again.
Okay, I tried it again with 3.2.0-preview.2 on https://github.com/gaffo/CSharpHotChocolateZeroQLIntegrationTestExample/tree/ZQL-21 and it fails with the query issue on all 3 integration tests... with 3.2.0-preview.4 and a clean build it works. So seems to have been identified and fixed in 3.2.0-preview.3 or 3.2.0-preview.4... you can see the diff at https://github.com/gaffo/CSharpHotChocolateZeroQLIntegrationTestExample/commit/7b5867eb2f3ba580816679139047439308547ee7 and it looks like it's entirely contained in the library since the generated code is unchanged.
@gaffo, I managed to reproduce the issue on your repository. Steps are next:
When you compile the tests project it emits warnings like that:
An instance of analyzer ZeroQL.SourceGenerators.Analyzers.QueryLambdaAnalyzer cannot be created from C:\Users\silin\.nuget\packages\zeroql\3.2.0-preview.2\analyzers\dotnet\cs\ZeroQL.SourceGenerators.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.4.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified..
If you run any test it will fail with the Query is not bootstrapped
error.
However, if I use 3.2.0-preview.4 it works fine.
I tried it again with 3.2.0-preview.4
Have you meant 3.2.0-preview.2?
I updated my comment... you are correct .2 fails, .4 works...
Any way to make that warning an error instead it seems that should just fail during build.
I'm getting the above error when executing a query using the classes, methods, and schema specified in your example. Looking at the source it seems like this error happens when the GraphQLQueryStore.Executor.TryGetValue returns null. When is this dictionary value being set?