ChilliCream / ChilliCream/graphql-platform

StrawberryShake code generator behaves differently to persisted query file writer

Open
#6,005 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🌶️ strawberry shake Area: Persisted Queries
Dominant language
C#
Stars
5.8k
Forks
810
Avg merge
15h 39m
Merged PRs (30d)
98

Description

Is there an existing issue for this?
  • I have searched the existing issues
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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the StrawberryShake CSharpGenerator with the persisted query file writer, tracing settings.RequestStrategy alongside GraphQLPersistedQueryOutput and GraphQLPersistedQueryFormat. Check how the .graphqlrc setting and MSBuild properties are resolved. Done means generated request behavior and persisted-query output are consistent across Debug and Release configurations, with coverage for the precedence behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.