FSharp.Data.GraphQL icon indicating copy to clipboard operation
FSharp.Data.GraphQL copied to clipboard

Same query name causes type provider to use the first one

Open xperiandri opened this issue 4 years ago • 5 comments

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

xperiandri avatar Mar 16 '20 07:03 xperiandri

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.

johnberzy-bazinga avatar Mar 22 '20 19:03 johnberzy-bazinga

I'm okay with that just adding a design-time error would be extremely helpful!

xperiandri avatar Mar 22 '20 20:03 xperiandri

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.

johnberzy-bazinga avatar Mar 22 '20 21:03 johnberzy-bazinga

Can we use the query file name instead of (or in conjunction to) query name as its identifier?

xperiandri avatar Mar 24 '20 22:03 xperiandri

We could, but it still wouldn't solve the problem of inline queries.

johnberzy-bazinga avatar Mar 24 '20 23:03 johnberzy-bazinga