FSharp.Data.GraphQL
FSharp.Data.GraphQL copied to clipboard
The type 'Schema<Root>' does not define the field, constructor or member 'AsyncExecute'
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 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)