FSharp.Data.GraphQL
FSharp.Data.GraphQL copied to clipboard
Client type provider fails to compile using local json schema, .NET Core 3.0
Description
I'm trying to use the type provider in a .NET Core 3.0 app and experience the following compiler error:
error FS3021: Unexpected exception from provided type 'FSharp.Data.GraphQL.GraphQLProvider,introspection="shopify_schema.json"' member 'GetMethods': The type provider 'FSharp.Data.GraphQL.Client.GraphQLTypeProvider' reported an error: Object reference not set to an instance of an object.
Snippet of affected code:
module Client =
type private ShopifyProvider = GraphQLProvider<"shopify_schema.json">
let private getRuntimeContext (shop:string) (token:string) =
{ ServerUrl = sprintf "https://%s.myshopify.com/admin/api/2019-10/graphq.json" shop
HttpHeaders = [("X-Shopify-Access-Token", token)] }
let createMetafields (sl:ServiceLocator) shop token =
let logger = sl.GetLogger (_moduleType.FullName)
let http = sl.GetService<IHttpClientFactory>().CreateClient()
let context = getRuntimeContext shop token
ShopifyProvider.Operation<"""mutation product {
}""">()
Repro steps
Please provide the steps required to reproduce the problem
-
Used
apollo
to download schema in json format from Shopify's Admin GraphQL API -
Add FSharp.Data.GraphQL.Client nupkg to
paket.dependencies
andpaket.references
for this project. -
Use type provider as indicated in the examples and in the README
Expected behavior
Type provider compiles, and compiled types interact correctly with autocomplete/intellisense.
Actual behavior
Compiler fails.
Known workarounds
Please provide a description of any known workarounds.
Related information
- Operating system: Windows 10 1903
- Branch: unsure
- .NET Runtime, CoreCLR or Mono Version: .NET Core 3.0
@aggieben Do you mind sending me the schema? Also, can you send me the actual mutation you're submitting (or one that reproduces the issue)?
Thanks, John
Sure, I don't mind. This is what I generated using apollo against the Shopify API (documented here: https://help.shopify.com/en/api/graphql-admin-api). shopify_schema.zip
The mutation above is just cruft, really. The issue manifests before I even wrote those lines. This line:
type private ShopifyProvider = GraphQLProvider<"shopify_schema.json">
failed all by itself.
I think this must have been caused by the particular json schema that was generated by apollo. I generated schema with a different tool (graphql schema
with the graphql cli) and the type provider seems to be happier with that. That's not to say there isn't still an issue here, but at least we can know it's not completely broken.
For reference, the schema that seems to be working: shopify_admin.json.zip
Another bit: I generated a json schema using the introspection query from the README, and the provider seems happy enough with that. I don't know the differences between the produced schemas.
@aggieben It may be that the introspection query in Apollo has changed (or maybe you're using an old version of apollo server?). In the near future we are hoping to also support the SDL format. We're going to need to update the parser before we can do that.
I have this same problem using graphql schema form github.
Try with the latest preview packages from the GitHub feed
It should work in 2.0.0, try again, please