FSharp.Data.GraphQL
FSharp.Data.GraphQL copied to clipboard
GraphQLProvider based on ISchema
Is it possible, in theory, to have GraphQLProvider based on ISchema instead of schema input as just text, file, or URL?
If yes, why is it not there? For no particular reason, or was it considered not practically useful, or something else?
I am thinking of some useful applications in scripting scenarios, for example:
- A host exposes its data model as
MySchema<MyRoot>. - A consumer (F# script) creates
GraphQLProvider<MySchema<MyRoot>>and works with strongly checked / typed operations and results.
It's currently not possible since Type Providers can't accept types as static input.
see: https://github.com/fsharp/fslang-suggestions/issues/212
Also, not sure this is desirable as clients would need to take a dependency on server related binaries. I guess it's possible we have some sort of interface that both the client and server model their schema based off of, but I'm not sure if that will really buy us much over our current mechanism.
Best Regards, John
Also, not sure this is desirable as clients would need to take a dependency on server related binaries.
Like I mentioned, my primary potential scenario is F# scripting, for example using FSharp.Compiler.Service library.
That is, I have a host app or library which exposes its data model via FSharp.Data.GraphQL ISchema. All the "server related binaries" are there, together with this app or library. F# scripting does not mind to take dependency on them, there is nothing extra needed to install or download.
I'm not sure if that will really buy us much over our current mechanism.
With our current mechanism, what steps do you recommend in my scenario? What should F# scripts do in order to invoke GraphQL query on a referenced library which defines and exposes ISchema and the executor? They can use the executor of course but the results are not strongly typed. That is why I think that engaging GraphQLProvider would be very useful for scripting (but not limited to).
It's currently not possible since Type Providers can't accept types as static input.
But this of course answers and probably closes my question. Closing?
@nightroman
In your scripting scenario, would the host application be able to initialize the executor and have the executor dump the graphql schema as a json file?
If that's the case, maybe the GraphQLProvider can just consume it after the host outputs the file the first time?
Thanks John
@jberzy Yes, we probably can do that. May I ask how? (sorry, still learning and there is not much manuals or examples).
Namely, how to dump JSON schema and how to engage the executor with GraphQLProvider? The provider is supposed to invoke queries by Run(ctx) with context based on some URL. In our scenario there is no URL or HTTP server as such.
See Build project, Program.fs, UpdateIntrospectionFile target. Feel free to reopen if necessary