Skip to content

Commit b7cbcf9

Browse files
committed
Included and fixed FSharp.Data.GraphQL.Tests.Sql
1 parent b904b04 commit b7cbcf9

File tree

9 files changed

+157
-159
lines changed

9 files changed

+157
-159
lines changed

FSharp.Data.GraphQL.sln

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{ED8079DD
8989
EndProject
9090
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Data.GraphQL.Tests", "tests\FSharp.Data.GraphQL.Tests\FSharp.Data.GraphQL.Tests.fsproj", "{54AAFE43-FA5F-485A-AD40-0240165FC633}"
9191
EndProject
92+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Data.GraphQL.Tests.Sql", "tests\FSharp.Data.GraphQL.Tests.Sql\FSharp.Data.GraphQL.Tests.Sql.fsproj", "{AC3963FE-427B-4E49-A1BF-EA6B024B2CE8}"
93+
EndProject
9294
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSharp.Data.GraphQL.Benchmarks", "tests\FSharp.Data.GraphQL.Benchmarks\FSharp.Data.GraphQL.Benchmarks.fsproj", "{A6A162DF-9FBB-4C2A-913F-FD5FED35A09B}"
9395
EndProject
9496
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{B0C25450-74BF-40C2-9E02-09AADBAE2C2F}"
@@ -210,6 +212,18 @@ Global
210212
{225B0790-C6B6-425C-9093-F359A4C635D3}.Release|x64.Build.0 = Release|Any CPU
211213
{225B0790-C6B6-425C-9093-F359A4C635D3}.Release|x86.ActiveCfg = Release|Any CPU
212214
{225B0790-C6B6-425C-9093-F359A4C635D3}.Release|x86.Build.0 = Release|Any CPU
215+
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
216+
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
217+
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Debug|x64.ActiveCfg = Debug|Any CPU
218+
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Debug|x64.Build.0 = Debug|Any CPU
219+
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Debug|x86.ActiveCfg = Debug|Any CPU
220+
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Debug|x86.Build.0 = Debug|Any CPU
221+
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
222+
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Release|Any CPU.Build.0 = Release|Any CPU
223+
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Release|x64.ActiveCfg = Release|Any CPU
224+
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Release|x64.Build.0 = Release|Any CPU
225+
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Release|x86.ActiveCfg = Release|Any CPU
226+
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Release|x86.Build.0 = Release|Any CPU
213227
{6768EA38-1335-4B8E-BC09-CCDED1F9AAF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
214228
{6768EA38-1335-4B8E-BC09-CCDED1F9AAF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
215229
{6768EA38-1335-4B8E-BC09-CCDED1F9AAF6}.Debug|x64.ActiveCfg = Debug|Any CPU
@@ -342,18 +356,18 @@ Global
342356
{A6A162DF-9FBB-4C2A-913F-FD5FED35A09B}.Release|x64.Build.0 = Release|Any CPU
343357
{A6A162DF-9FBB-4C2A-913F-FD5FED35A09B}.Release|x86.ActiveCfg = Release|Any CPU
344358
{A6A162DF-9FBB-4C2A-913F-FD5FED35A09B}.Release|x86.Build.0 = Release|Any CPU
345-
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
346-
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
347-
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Debug|x64.ActiveCfg = Debug|Any CPU
348-
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Debug|x64.Build.0 = Debug|Any CPU
349-
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Debug|x86.ActiveCfg = Debug|Any CPU
350-
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Debug|x86.Build.0 = Debug|Any CPU
351-
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
352-
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Release|Any CPU.Build.0 = Release|Any CPU
353-
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Release|x64.ActiveCfg = Release|Any CPU
354-
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Release|x64.Build.0 = Release|Any CPU
355-
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Release|x86.ActiveCfg = Release|Any CPU
356-
{C24EB38E-326C-4770-BB20-9838694EE5E6}.Release|x86.Build.0 = Release|Any CPU
359+
{AC3963FE-427B-4E49-A1BF-EA6B024B2CE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
360+
{AC3963FE-427B-4E49-A1BF-EA6B024B2CE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
361+
{AC3963FE-427B-4E49-A1BF-EA6B024B2CE8}.Debug|x64.ActiveCfg = Debug|Any CPU
362+
{AC3963FE-427B-4E49-A1BF-EA6B024B2CE8}.Debug|x64.Build.0 = Debug|Any CPU
363+
{AC3963FE-427B-4E49-A1BF-EA6B024B2CE8}.Debug|x86.ActiveCfg = Debug|Any CPU
364+
{AC3963FE-427B-4E49-A1BF-EA6B024B2CE8}.Debug|x86.Build.0 = Debug|Any CPU
365+
{AC3963FE-427B-4E49-A1BF-EA6B024B2CE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
366+
{AC3963FE-427B-4E49-A1BF-EA6B024B2CE8}.Release|Any CPU.Build.0 = Release|Any CPU
367+
{AC3963FE-427B-4E49-A1BF-EA6B024B2CE8}.Release|x64.ActiveCfg = Release|Any CPU
368+
{AC3963FE-427B-4E49-A1BF-EA6B024B2CE8}.Release|x64.Build.0 = Release|Any CPU
369+
{AC3963FE-427B-4E49-A1BF-EA6B024B2CE8}.Release|x86.ActiveCfg = Release|Any CPU
370+
{AC3963FE-427B-4E49-A1BF-EA6B024B2CE8}.Release|x86.Build.0 = Release|Any CPU
357371
EndGlobalSection
358372
GlobalSection(SolutionProperties) = preSolution
359373
HideSolutionNode = FALSE
@@ -363,6 +377,7 @@ Global
363377
{78D10788-601D-4D53-808B-36661911EDD1} = {56640EAF-82A6-4439-AD14-69F44A90DA99}
364378
{B837B3ED-83CE-446F-A4E5-44CB06AA6505} = {B0C25450-74BF-40C2-9E02-09AADBAE2C2F}
365379
{225B0790-C6B6-425C-9093-F359A4C635D3} = {B0C25450-74BF-40C2-9E02-09AADBAE2C2F}
380+
{C24EB38E-326C-4770-BB20-9838694EE5E6} = {B0C25450-74BF-40C2-9E02-09AADBAE2C2F}
366381
{6768EA38-1335-4B8E-BC09-CCDED1F9AAF6} = {BEFD8748-2467-45F9-A4AD-B450B12D5F78}
367382
{474179D3-0090-49E9-88F8-2971C0966077} = {BEFD8748-2467-45F9-A4AD-B450B12D5F78}
368383
{554A6833-1E72-41B4-AAC1-C19371EC061B} = {BEFD8748-2467-45F9-A4AD-B450B12D5F78}
@@ -385,7 +400,7 @@ Global
385400
{A8F031E0-2BD5-4BAE-830A-60CBA76A047D} = {600D4BE2-FCE0-4684-AC6F-2DC829B395BA}
386401
{6EEA0E79-693F-4D4F-B55B-DB0C64EBDA45} = {600D4BE2-FCE0-4684-AC6F-2DC829B395BA}
387402
{7AA3516E-60F5-4969-878F-4E3DCF3E63A3} = {A8F031E0-2BD5-4BAE-830A-60CBA76A047D}
388-
{C24EB38E-326C-4770-BB20-9838694EE5E6} = {B0C25450-74BF-40C2-9E02-09AADBAE2C2F}
403+
{AC3963FE-427B-4E49-A1BF-EA6B024B2CE8} = {ED8079DD-2B06-4030-9F0F-DC548F98E1C4}
389404
EndGlobalSection
390405
GlobalSection(ExtensibilityGlobals) = postSolution
391406
SolutionGuid = {C5B9895C-9DF8-4557-8D44-7D0C4C31F86E}

Packages.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
<PackageReference Update="Microsoft.Diagnostics.Tracing.TraceEvent" Version="3.*" />
8585
<PackageReference Update="Microsoft.NETCore.Platforms" Version="6.0.*" />
8686
<PackageReference Update="Newtonsoft.Json" Version="13.*" />
87+
<PackageReference Update="SQLProvider" Version="1.4.*" />
8788
<PackageReference Update="System.Data.Common" Version="4.3.0" />
8889
<PackageReference Update="Thoth.Json.Net" Version="12.0.0" />
8990
<PackageReference Update="Validus" Version="4.1.*" />

src/FSharp.Data.GraphQL.Server/Linq.fs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ type Track =
7070
type Tracker =
7171
/// Leaf of the tree. Marks a direct field/property access with no sub-trees.
7272
/// Consists of <see cref="Track"/> record and (neglible in this case) list of arguments.
73-
| Direct of Track * Arg list
73+
| Direct of Track * Arg Set
7474
/// Marks branched field/property access - property value withh possible sub-trees.
7575
/// Consists of <see cref="Track"/> record list of arguments used to parametrize GraphQL
7676
/// field definition and set of subtrees.
77-
| Compose of Track * Arg list * Set<Tracker>
77+
| Compose of Track * Arg Set * Tracker Set
7878
member x.Track =
7979
match x with
8080
| Direct(track, _) -> track
@@ -134,7 +134,7 @@ type CallableArg =
134134
Argument: Arg
135135
/// List of all other arguments resolved as part of other possible
136136
/// applications on the current property track.
137-
AllArguments: Arg list
137+
AllArguments: Arg Set
138138
/// Track describing field or property access.
139139
Track: Track
140140
/// Source type of the property - in case when track returns a collection or option,
@@ -219,7 +219,7 @@ let private applyFirst: ArgApplication = fun expression callable ->
219219
let orderBy = methods.OrderBy.MakeGenericMethod [| tSource; idAccess.ReturnType |]
220220
let ordered = Expression.Call(null, orderBy, expression, idAccess)
221221

222-
let afterOption = callable.AllArguments |> List.tryFind (fun a -> a.Name = "after")
222+
let afterOption = callable.AllArguments |> Seq.tryFind (fun a -> a.Name = "after")
223223
let result =
224224
match afterOption with
225225
| Some(after) ->
@@ -244,7 +244,7 @@ let private applyLast: ArgApplication = fun expression callable ->
244244
let orderByDesc = methods.OrderByDesc.MakeGenericMethod [| tSource; idAccess.ReturnType |]
245245
let ordered = Expression.Call(null, orderByDesc, expression, idAccess)
246246

247-
let beforeOption = callable.AllArguments |> List.tryFind (fun a -> a.Name = "after")
247+
let beforeOption = callable.AllArguments |> Seq.tryFind (fun a -> a.Name = "after")
248248
let result =
249249
match beforeOption with
250250
| Some(before) ->
@@ -262,13 +262,13 @@ let private applyLast: ArgApplication = fun expression callable ->
262262
/// from a given ExecutionInfo and variables collection
263263
let private linqArgs vars info =
264264
let argDefs = info.Definition.Args
265-
if Array.isEmpty argDefs then []
265+
if Array.isEmpty argDefs then Set.empty
266266
else
267267
let args = info.Ast.Arguments
268268
argDefs
269-
|> Array.map (fun a -> (a.Name, a, args |> List.tryFind (fun x -> x.Name = a.Name)))
270-
|> Array.choose (resolveLinqArg vars)
271-
|> Array.toList
269+
|> Seq.map (fun a -> (a.Name, a, args |> List.tryFind (fun x -> x.Name = a.Name)))
270+
|> Seq.choose (resolveLinqArg vars)
271+
|> Set.ofSeq
272272

273273
let rec private track set e =
274274
match e with
@@ -388,7 +388,7 @@ let rec private infoComposer (root: Tracker) (allTracks: Set<Tracker>) : Set<Tra
388388
|> Set.filter (fun track ->
389389
match track with
390390
| Direct (track, _) -> canJoin grandpaType track.ParentType && isOwn track
391-
| x -> failwith <| sprintf "Expected Direct Track, but got %A" x)
391+
| x -> failwithf "Expected Direct Track, but got %A" x)
392392
if Set.isEmpty members
393393
then root |> Set.singleton
394394
else
@@ -426,7 +426,7 @@ let rec private getTracks alreadyFound info =
426426
| _ -> failwith <| sprintf "Unexpected Resolve Definition Expression!"
427427
let tracks =
428428
track Set.empty expr
429-
|> Set.map(fun track -> Direct(track, []))
429+
|> Set.map(fun track -> Direct(track, Set.empty))
430430
|> flip Set.difference alreadyFound
431431
match info.Kind with
432432
| ResolveDeferred inner -> getTracks alreadyFound inner
@@ -568,7 +568,7 @@ and private constructCollection argApplicators tracker (inParam: Expression) : E
568568
Expression.Convert(inParam, methods.Type.MakeGenericType [| tSource |]),
569569
// `mapFunc` param - (p0 => body )
570570
Expression.Lambda(body, p0))
571-
let final = args |> List.fold (fun acc (arg: Arg) ->
571+
let final = args |> Set.fold (fun acc (arg: Arg) ->
572572
match Map.tryFind (arg.Name.ToLowerInvariant()) argApplicators with
573573
| Some apply -> apply acc { AllArguments = args; Argument = arg; Track = track; Fields = fields; Type = tSource }
574574
| None -> acc) call

tests/FSharp.Data.GraphQL.Tests.Sql/AssemblyInfo.fs

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
33
<PropertyGroup>
4-
<TargetFrameworks>net47</TargetFrameworks>
5-
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
4+
<TargetFramework>$(DotNetVersion)</TargetFramework>
65
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
6+
<GenerateProgramFile>false</GenerateProgramFile>
7+
<OutputType>Exe</OutputType>
78
</PropertyGroup>
8-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
9-
<DebugSymbols>true</DebugSymbols>
10-
<DebugType>full</DebugType>
11-
</PropertyGroup>
9+
1210
<ItemGroup>
13-
<Compile Include="AssemblyInfo.fs" />
14-
<Compile Include="Helpers.fs" />
15-
<Compile Include="LinqToSqlTests.fs" />
11+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
12+
<PackageReference Include="BenchmarkDotNet" />
13+
<PackageReference Include="SQLProvider" />
14+
<PackageReference Include="Validus" />
15+
<PackageReference Include="xunit" />
16+
<PackageReference Include="xunit.runner.utility" />
17+
<PackageReference Include="xunit.runner.visualstudio" />
1618
</ItemGroup>
19+
1720
<ItemGroup>
18-
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
21+
<Compile Include="Helpers.fs" />
22+
<Compile Include="LinqToSqlTests.fs" />
1923
</ItemGroup>
24+
2025
<ItemGroup>
2126
<ProjectReference Include="..\..\src\FSharp.Data.GraphQL.Shared\FSharp.Data.GraphQL.Shared.fsproj" />
2227
<ProjectReference Include="..\..\src\FSharp.Data.GraphQL.Server\FSharp.Data.GraphQL.Server.fsproj" />
2328
</ItemGroup>
24-
<Import Project="..\..\.paket\Paket.Restore.targets" />
2529
</Project>
Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/// The MIT License (MIT)
2-
/// Copyright (c) 2016 Bazinga Technologies Inc
1+
// The MIT License (MIT)
2+
// Copyright (c) 2016 Bazinga Technologies Inc
33
[<AutoOpen>]
44
module Helpers
55

@@ -11,26 +11,23 @@ open FSharp.Data.GraphQL.Types
1111
open FSharp.Data.GraphQL.Types.Introspection
1212
open FSharp.Data.GraphQL.Execution
1313

14-
let equals (expected : 'x) (actual : 'x) =
15-
Assert.True((actual = expected), sprintf "expected %+A\nbut got %+A" expected actual)
16-
let noErrors (result: IDictionary<string, obj>) =
17-
match result.TryGetValue("errors") with
14+
let equals (expected : 'x) (actual : 'x) =
15+
Assert.True ((actual = expected), sprintf "expected %+A\nbut got %+A" expected actual)
16+
let noErrors (result : IDictionary<string, obj>) =
17+
match result.TryGetValue ("errors") with
1818
| true, errors -> failwithf "expected ExecutionResult to have no errors but got %+A" errors
1919
| false, _ -> ()
20-
let throws<'e when 'e :> exn> (action : unit -> unit) = Assert.Throws<'e>(action)
20+
let throws<'e when 'e :> exn> (action : unit -> unit) = Assert.Throws<'e> (action)
2121
let sync = Async.RunSynchronously
22-
let is<'t> (o: obj) = o :? 't
23-
let hasError errMsg (errors: string seq) =
24-
let containsMessage =
25-
errors
26-
|> Seq.exists (fun e -> e.Contains(errMsg))
27-
Assert.True (containsMessage, sprintf "expected to contain message '%s', but no such message was found. Messages found: %A" errMsg errors)
22+
let is<'t> (o : obj) = o :? 't
23+
let hasError (errMsg : string) (errors : string seq) =
24+
let containsMessage = errors |> Seq.exists (fun e -> e.Contains (errMsg))
25+
Assert.True (containsMessage, $"expected to contain message '%s{errMsg}', but no such message was found. Messages found: %A{errors}")
2826

29-
let (<??) opt other =
27+
let (<??) opt other =
3028
match opt with
3129
| None -> Some other
3230
| _ -> opt
3331

34-
let undefined (value: 't) =
35-
Assert.True((value = Unchecked.defaultof<'t>), sprintf "Expected value to be undefined, but was: %A" value)
36-
32+
let undefined (value : 't) =
33+
Assert.True ((value = Unchecked.defaultof<'t>), $"Expected value to be undefined, but was: %A{value}")
Lines changed: 52 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,71 @@
1-
/// The MIT License (MIT)
2-
/// Copyright (c) 2016 Bazinga Technologies Inc
1+
// The MIT License (MIT)
2+
// Copyright (c) 2016 Bazinga Technologies Inc
33

44
module FSharp.Data.GraphQL.Tests.LinqToSqlTests
55

66
open System
77
open System.Linq
88
open Xunit
9-
open FSharp.Data.TypeProviders
9+
open FSharp.Data.Sql
1010
open FSharp.Data.GraphQL
1111
open FSharp.Data.GraphQL.Parser
1212
open FSharp.Data.GraphQL.Types
1313
open FSharp.Data.GraphQL.Execution
1414
open FSharp.Data.GraphQL.Linq
1515

16-
type Db = SqlDataConnection<"Server=.;Database=NORTHWND;Trusted_Connection=True;">
16+
// https://github.com/microsoft/sql-server-samples/blob/master/samples/databases/northwind-pubs/instnwnd.sql
17+
type Db =
18+
SqlDataProvider<
19+
Common.DatabaseProviderTypes.MSSQLSERVER,
20+
"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Northwnd;Integrated Security=True;Encrypt=False;"
21+
>
1722

18-
let Order = Define.Object("Order", [
19-
Define.Field("orderId", ID, fun _ (o: Db.ServiceTypes.Orders) -> o.OrderID)
20-
Define.Field("shipAddress", String, fun _ o -> o.ShipAddress)
21-
Define.Field("shipCity", String, fun _ o -> o.ShipCity)
22-
Define.Field("shipCountry", String, fun _ o -> o.ShipCountry) ])
23+
let OrderType =
24+
Define.Object<Db.dataContext.``dbo.OrdersEntity``> (
25+
"Order",
26+
[
27+
Define.Field ("orderId", IDType, resolve = (fun _ o -> o.OrderId |> string))
28+
Define.Field ("shipAddress", StringType, resolve = (fun _ o -> o.ShipAddress))
29+
Define.Field ("shipCity", StringType, resolve = (fun _ o -> o.ShipCity))
30+
Define.Field ("shipCountry", StringType, resolve = (fun _ o -> o.ShipCountry))
31+
]
32+
)
33+
34+
let Customer =
35+
Define.Object<Db.dataContext.``dbo.CustomersEntity``> (
36+
"Customer",
37+
[
38+
Define.Field ("customerID", IDType, resolve = (fun _ c -> c.CustomerId))
39+
Define.Field ("contactName", StringType, resolve = (fun _ c -> c.ContactName))
40+
Define.Field ("orders", ListOf OrderType, resolve = (fun _ c -> c.``dbo.Orders by CustomerID``))
41+
]
42+
)
2343

24-
let Customer = Define.Object("Customer", [
25-
Define.Field("customerID", ID, fun _ (c: Db.ServiceTypes.Customers) -> c.CustomerID)
26-
Define.Field("contactName", String, fun _ c -> c.ContactName)
27-
Define.Field("orders", ListOf Order, fun _ c -> c.Orders) ])
28-
2944
[<Fact>]
3045
let ``LINQ: should create an executable flat SQL query`` () =
31-
let schema = Schema(Define.Object("RootQuery", [
32-
Define.Field("customers", ListOf Customer, fun ctx (dbContext: Db.ServiceTypes.SimpleDataContextTypes.NORTHWND) ->
33-
let query = ctx.ExecutionPlan.ToLinq(dbContext.Customers)
34-
query |> Seq.toList) ]))
35-
let query = parse """{
46+
let schema =
47+
Schema (
48+
Define.Object (
49+
"RootQuery",
50+
[
51+
Define.Field (
52+
"customers",
53+
ListOf Customer,
54+
fun ctx (dbContext : Db.dataContext) ->
55+
let query = dbContext.Dbo.Customers.Apply (ctx.ExecutionInfo, ctx.Variables)
56+
query |> Seq.toList
57+
)
58+
]
59+
)
60+
)
61+
let query =
62+
parse
63+
"""query {
3664
customers {
3765
contactName
38-
}
66+
}
3967
}"""
40-
use db = Db.GetDataContext()
41-
let result = sync <| schema.AsyncExecute(query, db)
42-
()
68+
let db = Db.GetDataContext ()
69+
let executor = Executor<Db.dataContext> (schema)
70+
let result = sync <| executor.AsyncExecute (query, db)
71+
()

0 commit comments

Comments
 (0)