ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.25k stars 745 forks source link

StrawberryShake code generator behaves differently to persisted query file writer #6005

Open benmccallum opened 1 year ago

benmccallum commented 1 year ago

Is there an existing issue for this?

Product

Strawberry Shake

Describe the bug

Seems to be now that the CSharpGenerator respects the settings.RequestStrategy (coming from the .graphqlrc file direct?) rather than being influenced by any of the MSBuild properties that influence the writing of the persisted query file to the query output directory.

Before (v12): If you didn't specify GraphQLPersistedQueryOutput property (default is "") nor the GraphQLPersistedQueryFormat (default is "default"), even if your .graphqlrc.json file specified the PersistedQuery strategy, you:

  1. wouldn't get the persisted query file written, and
  2. the CSharp code would use the Default strategy for operation requests.

This was great because you could do the following to run without persisted queries during Development.

<GraphQLPersistedQueryOutput Condition="'$(Configuration)' != 'Debug'">$(MSBuildProjectDirectory)\..\$(MSBuildProjectName)PersistedQueries</GraphQLPersistedQueryOutput>

Now (v13):

  1. you don't get the query file written (same as before)
  2. the CSharp code uses the PersistedQuery strategy (damn!)

It feels like these two things should operate the same. For now, the only way to get different behaviour between Debug and Release builds would be to edit the .graphqlrc file on the fly, right?

To restore the old behaviour, it might be best to introduce GraphQLPersistedRequestStrategy property that takes precedence over the rc setting file.

Steps to reproduce

Relevant log output

No response

Additional Context?

No response

Version

13.0.5

benmccallum commented 1 year ago

Right now I've set the config files to use Default and am updating them to use PersistedQuery as part of our build process (not the worst solution to be honest, but not as easy to debug :P).

Default is ideal on localhost as I don't want to be pushing new queries up to redis while developin (we do that in our build pipeline too).