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

The type 'Schema<Root>' does not define the field, constructor or member 'AsyncExecute'

Open mjarosie opened this issue 4 years ago • 1 comments

Description

The example code shown in the Quick start section in the home page doesn't compile, showing the following error:

The type 'Schema<Root>' does not define the field, constructor or member 'AsyncExecute'

Repro steps

Code, exactly as in the quick start section:

type Person = { FirstName: string; LastName: string }
let people = [ 
    { FirstName = "Jane"; LastName = "Milton" }
    { FirstName = "Travis"; LastName = "Smith" } ]

open FSharp.Data.GraphQL
open FSharp.Data.GraphQL.Types

// GraphQL type definition for Person type
let Person = Define.Object("Person", [
    Define.Field("firstName", String, fun ctx p -> p.FirstName)
    Define.Field("lastName", String, fun ctx p -> p.LastName)  
])

// each schema must define so-called root query
let QueryRoot = Define.Object("Query", [
    Define.Field("people", ListOf Person, fun ctx () -> people)
])

// then initialize everything as part of schema
let schema = Schema(QueryRoot)

open FSharp.Data.GraphQL.Execution
let query = """
    query Example {
        people {
            firstName
        }
    }
    """
async {
    let! response = schema.AsyncExecute(query) // Here's the error.
    printf "%A" response
}

Expected behavior

Code example is fixed and works out of the box.

Actual behavior

The following error occurs:

The type 'Schema<Root>' does not define the field, constructor or member 'AsyncExecute'

Related information

FSharp.Data.GraphQL.Server: v1.0.5

mjarosie avatar Oct 20 '20 14:10 mjarosie

@mjarosie I resolved this problem using the Executor, seems more like a document issue:

open FSharp.Data.GraphQL

let executor = Executor(schema)
let! response = executor.AsyncExecute(query)

brunurd avatar Jan 10 '21 16:01 brunurd