You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Open the solution and generate the client on both windows and mac
Inspect the client cs file that it generated.
What is expected?
In the IProjectFragment interface, the interface type of the Manager property should be the same type as that on Mac and Windows.
What is actually happening?
It's not, and this is a huge problem because it results in differently named and incompatible interfaces depending on which OS you use to compile the solution. On Mac it is IProjectSearchQuery_ProjectSearch_Manager and on Windows it is IProjectQuery_ProjectSearch_Manager
This is happening because the GeneratorHelpers.GetGraphQLDocuments method in src/StrawberryShake/Tooling/src/dotnet-graphql/GeneratorHelpers.cs does not order the files, and the order returned by default is different on Mac vs Windows. Since there are two queries that share a fragment, the name is composed of which ever query is processed first.
Mac Order
GraphDocuments\01_ProjectQuery.graphql (therefore "ProjectQuery" is used in the type name)
GraphDocuments\02_ProjectSearchQuery.graphql
GraphDocuments\ProjectFragment.graphql
Windows Order
GraphDocuments/ProjectFragment.graphql
GraphDocuments/02_ProjectSearchQuery.graphql (therefore "ProjectSearchQuery" is used in the type name)
GraphDocuments/01_ProjectQuery.graphql
Possible Solutions
The code should name the fragment types independently and not include name parts from any queries i.e. it could be IProjectFragment_Manager and not IProjectQuery_ProjectSearch_Manager
Ensure the file order is consistent (and therefore the type creation and naming is consistent), I believe the code in GetGraphQLDocuments needs to order the files found as follows OrderBy(s => s, StringComparer.InvariantCulture).
Any fix would likely need to be opted in via a configuration setting to avoid breaking behavioural change.
Relevant log output
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
glen-84
changed the title
unsorted glob files result in non-deterministic client generation on windows vs mac
Unsorted glob files result in non-deterministic client generation on windows vs mac
Jun 26, 2024
pm7y
changed the title
Unsorted glob files result in non-deterministic client generation on windows vs mac
Unsorted glob files result in inconsistent client generation on windows vs mac
Jun 26, 2024
pm7y
changed the title
Unsorted glob files result in inconsistent client generation on windows vs mac
Inconsistent client generation on Windows vs Mac
Jun 26, 2024
Product
Strawberry Shake
Version
latest
Link to minimal reproduction
https://github.com/pm7y/StrawberryShakeBugRepro
Steps to reproduce
What is expected?
In the
IProjectFragment
interface, the interface type of theManager
property should be the same type as that on Mac and Windows.What is actually happening?
It's not, and this is a huge problem because it results in differently named and incompatible interfaces depending on which OS you use to compile the solution. On Mac it is
IProjectSearchQuery_ProjectSearch_Manager
and on Windows it isIProjectQuery_ProjectSearch_Manager
This is happening because the
GeneratorHelpers.GetGraphQLDocuments
method insrc/StrawberryShake/Tooling/src/dotnet-graphql/GeneratorHelpers.cs
does not order the files, and the order returned by default is different on Mac vs Windows. Since there are two queries that share a fragment, the name is composed of which ever query is processed first.Mac Order
(therefore "ProjectQuery" is used in the type name)
Windows Order
(therefore "ProjectSearchQuery" is used in the type name)
Possible Solutions
IProjectFragment_Manager
and notIProjectQuery_ProjectSearch_Manager
GetGraphQLDocuments
needs to order the files found as followsOrderBy(s => s, StringComparer.InvariantCulture)
.Any fix would likely need to be opted in via a configuration setting to avoid breaking behavioural change.
Relevant log output
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: