FSharp.Data.GraphQL
FSharp.Data.GraphQL copied to clipboard
Same query name causes type provider to use the first one
Description
If you declare Different GraphQLProvider instances with the same query name then type provider compiles the first found query to all type provider generated code where query with the same name occurs
Repro steps
https://github.com/ZhenyaP/fsharp-graphql-client-sample
Expected behavior
Even though queries have the same name they are defined in different instances hence must be compiled with each defined query in each instance correspondently.
Actual behavior
Type provider cashes queries by name and then resolve each next query with the same name to the first one cached.
Known workarounds
Use different names for all queries throughout the project.
Related information
- Package FSharp.Data.GraphQL.Client
- Version 1.0.3
- .NET Core App 3.1, .NET Standard 2.0
This is really by design. We realize it's a bit of a pitfall. We can mangle the name, but the type name but it would need to be deterministic. Changing the name to add a hash of the query as a suffix means that modifying a query would result in a new type name.
I'm okay with that just adding a design-time error would be extremely helpful!
Yes. I don't know if there is a way to do that unfortunately. We can't differentiate between a query that's been updated (i.e. the same query being modified) vs. a new query with the same name as far as I know.
Can we use the query file name instead of (or in conjunction to) query name as its identifier?
We could, but it still wouldn't solve the problem of inline queries.