fsprojects / FSharp.Data.GraphQL

FSharp implementation of Facebook GraphQL query language.
http://fsprojects.github.io/FSharp.Data.GraphQL/
MIT License
394 stars 72 forks source link

Client type provider fails to compile using introspection #426

Closed michaelwinch closed 1 year ago

michaelwinch commented 1 year ago

Description

I have an Apollo server hosted on an AWS Lambda which I'm trying to set up the type provider to query. When I give it the url (which is globally accessible) I receive an error message and it doesn't compile.

However, querying the endpoint in Postman succeeds and Postman itself loads the schema, and gives me intellisense when writing a query. If I run the introspection query and use that json file as the schema it also works without problems.

Repro steps

  1. Create a basic GraphQLProvider like below
type Provider1 = GraphQLProvider<"https://<redacted>.lambda-url.eu-west-2.on.aws">
type Provider2 = GraphQLProvider<"../schema.json">
let op =
    Provider1.Operation<"""query MyQuery($customerId: ID!) {
        isAnOBCustomer(customerId: $customerId)
    }""">()

Expected behavior

I expect the code to compile and validate the query at design time

Actual behavior

I receive the error message: Unexpected exception from provided type 'FSharp.Data.GraphQL.GraphQLProvider,introspection="https://<redacted>.lambda-url.eu-west-2.on.aws/fg5"' member 'GetMethods': The type provider 'FSharp.Data.GraphQL.Client.GraphQLTypeProvider' reported an error: Type 'System.String' is not an F# record type. (Parameter 'recordType')

Known workarounds

Use a json file as the schema

Related information

michaelwinch commented 1 year ago

Closing this issue - it was a problem with the configuration of my lambda. On hindsight the most surprising part is that Postman was able to retrieve the schema.