Permalink
Browse files

create core scalar definitions for URIs and Dates

introduced compilation phase on schema creation

moved to Hopac

fs core downgrade

optimized interface/union completion
  • Loading branch information...
Horusiath committed Jun 13, 2016
1 parent b04e9c0 commit ebebebebf6d7886e43e39cab6c16d6f1cc40b2e7
Showing with 1,123 additions and 739 deletions.
  1. +22 −0 FSharp.Data.GraphQL.sln
  2. +1 −0 paket.dependencies
  3. +11 −9 paket.lock
  4. +12 −13 samples/graphiql-client/server.fsx
  5. +1 −1 src/FSharp.Data.GraphQL.Client/FSharp.Data.GraphQL.Client.fsproj
  6. +11 −11 src/FSharp.Data.GraphQL.Relay/Connections.fs
  7. +21 −0 src/FSharp.Data.GraphQL.Relay/FSharp.Data.GraphQL.Relay.fsproj
  8. +2 −2 src/FSharp.Data.GraphQL.Relay/Node.fs
  9. +1 −0 src/FSharp.Data.GraphQL.Relay/paket.references
  10. +7 −7 src/FSharp.Data.GraphQL/Ast.fs
  11. +334 −218 src/FSharp.Data.GraphQL/Execution.fs
  12. +48 −4 src/FSharp.Data.GraphQL/FSharp.Data.GraphQL.fsproj
  13. +18 −42 src/FSharp.Data.GraphQL/Introspection.fs
  14. +1 −1 src/FSharp.Data.GraphQL/Parser.fs
  15. +22 −0 src/FSharp.Data.GraphQL/Prolog.fs
  16. +69 −136 src/FSharp.Data.GraphQL/Schema.fs
  17. +195 −113 src/FSharp.Data.GraphQL/TypeSystem.fs
  18. +2 −1 src/FSharp.Data.GraphQL/paket.references
  19. +1 −1 tests/FSharp.Data.GraphQL.Benchmarks/App.config
  20. +5 −5 tests/FSharp.Data.GraphQL.Benchmarks/ExecutionBenchmark.fs
  21. +52 −51 tests/FSharp.Data.GraphQL.Benchmarks/FSharp.Data.GraphQL.Benchmarks.fsproj
  22. +79 −0 tests/FSharp.Data.GraphQL.Benchmarks/TraceEvent.ReadMe.txt
  23. +61 −0 tests/FSharp.Data.GraphQL.Benchmarks/TraceEvent.ReleaseNotes.txt
  24. BIN tests/FSharp.Data.GraphQL.Benchmarks/_TraceEventProgrammersGuide.docx
  25. +2 −1 tests/FSharp.Data.GraphQL.Benchmarks/paket.references
  26. +21 −21 tests/FSharp.Data.GraphQL.Tests/AbstractionTests.fs
  27. +2 −2 tests/FSharp.Data.GraphQL.Tests/DirectivesTests.fs
  28. +20 −20 tests/FSharp.Data.GraphQL.Tests/ExecutionTests.fs
  29. +24 −3 tests/FSharp.Data.GraphQL.Tests/FSharp.Data.GraphQL.Tests.fsproj
  30. +14 −14 tests/FSharp.Data.GraphQL.Tests/IntrospectionTests.fs
  31. +8 −8 tests/FSharp.Data.GraphQL.Tests/MutationTests.fs
  32. +1 −1 tests/FSharp.Data.GraphQL.Tests/ParserTests.fs
  33. +9 −9 tests/FSharp.Data.GraphQL.Tests/Relay/ConnectionTests.fs
  34. +7 −7 tests/FSharp.Data.GraphQL.Tests/Relay/NodeTests.fs
  35. +3 −3 tests/FSharp.Data.GraphQL.Tests/ResolveTests.fs
  36. +9 −9 tests/FSharp.Data.GraphQL.Tests/SchemaTests.fs
  37. +11 −11 tests/FSharp.Data.GraphQL.Tests/UnionInterfaceTests.fs
  38. +15 −15 tests/FSharp.Data.GraphQL.Tests/VariablesTests.fs
  39. +1 −0 tests/FSharp.Data.GraphQL.Tests/paket.references
View
@@ -76,29 +76,51 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{474179D3-0090-49E9-88F8-2971C0966077}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{474179D3-0090-49E9-88F8-2971C0966077}.Debug|Any CPU.Build.0 = Debug|Any CPU
{474179D3-0090-49E9-88F8-2971C0966077}.Debug|x64.ActiveCfg = Debug|x64
{474179D3-0090-49E9-88F8-2971C0966077}.Debug|x64.Build.0 = Debug|x64
{474179D3-0090-49E9-88F8-2971C0966077}.Release|Any CPU.ActiveCfg = Release|Any CPU
{474179D3-0090-49E9-88F8-2971C0966077}.Release|Any CPU.Build.0 = Release|Any CPU
{474179D3-0090-49E9-88F8-2971C0966077}.Release|x64.ActiveCfg = Release|x64
{474179D3-0090-49E9-88F8-2971C0966077}.Release|x64.Build.0 = Release|x64
{54AAFE43-FA5F-485A-AD40-0240165FC633}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{54AAFE43-FA5F-485A-AD40-0240165FC633}.Debug|Any CPU.Build.0 = Debug|Any CPU
{54AAFE43-FA5F-485A-AD40-0240165FC633}.Debug|x64.ActiveCfg = Debug|Any CPU
{54AAFE43-FA5F-485A-AD40-0240165FC633}.Debug|x64.Build.0 = Debug|Any CPU
{54AAFE43-FA5F-485A-AD40-0240165FC633}.Release|Any CPU.ActiveCfg = Release|Any CPU
{54AAFE43-FA5F-485A-AD40-0240165FC633}.Release|Any CPU.Build.0 = Release|Any CPU
{54AAFE43-FA5F-485A-AD40-0240165FC633}.Release|x64.ActiveCfg = Release|Any CPU
{54AAFE43-FA5F-485A-AD40-0240165FC633}.Release|x64.Build.0 = Release|Any CPU
{751357AE-F2B2-4B38-956E-81E0B8606C73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{751357AE-F2B2-4B38-956E-81E0B8606C73}.Debug|Any CPU.Build.0 = Debug|Any CPU
{751357AE-F2B2-4B38-956E-81E0B8606C73}.Debug|x64.ActiveCfg = Debug|x64
{751357AE-F2B2-4B38-956E-81E0B8606C73}.Debug|x64.Build.0 = Debug|x64
{751357AE-F2B2-4B38-956E-81E0B8606C73}.Release|Any CPU.ActiveCfg = Release|Any CPU
{751357AE-F2B2-4B38-956E-81E0B8606C73}.Release|Any CPU.Build.0 = Release|Any CPU
{751357AE-F2B2-4B38-956E-81E0B8606C73}.Release|x64.ActiveCfg = Release|x64
{751357AE-F2B2-4B38-956E-81E0B8606C73}.Release|x64.Build.0 = Release|x64
{C53B6C2C-35E0-46D1-8D01-59F19D345CB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C53B6C2C-35E0-46D1-8D01-59F19D345CB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C53B6C2C-35E0-46D1-8D01-59F19D345CB1}.Debug|x64.ActiveCfg = Debug|Any CPU
{C53B6C2C-35E0-46D1-8D01-59F19D345CB1}.Debug|x64.Build.0 = Debug|Any CPU
{C53B6C2C-35E0-46D1-8D01-59F19D345CB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C53B6C2C-35E0-46D1-8D01-59F19D345CB1}.Release|Any CPU.Build.0 = Release|Any CPU
{C53B6C2C-35E0-46D1-8D01-59F19D345CB1}.Release|x64.ActiveCfg = Release|Any CPU
{C53B6C2C-35E0-46D1-8D01-59F19D345CB1}.Release|x64.Build.0 = Release|Any CPU
{7C9CC625-FB4E-4215-9F7C-494AA6043821}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C9CC625-FB4E-4215-9F7C-494AA6043821}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C9CC625-FB4E-4215-9F7C-494AA6043821}.Debug|x64.ActiveCfg = Debug|Any CPU
{7C9CC625-FB4E-4215-9F7C-494AA6043821}.Debug|x64.Build.0 = Debug|Any CPU
{7C9CC625-FB4E-4215-9F7C-494AA6043821}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C9CC625-FB4E-4215-9F7C-494AA6043821}.Release|Any CPU.Build.0 = Release|Any CPU
{7C9CC625-FB4E-4215-9F7C-494AA6043821}.Release|x64.ActiveCfg = Release|Any CPU
{7C9CC625-FB4E-4215-9F7C-494AA6043821}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
@@ -2,6 +2,7 @@ source https://nuget.org/api/v2
nuget BenchmarkDotNet
nuget BenchmarkDotNet.Diagnostics.Windows
nuget FParsec
nuget Hopac
nuget Newtonsoft.Json
nuget Suave
View
@@ -1,12 +1,14 @@
NUGET
remote: https://www.nuget.org/api/v2
specs:
BenchmarkDotNet (0.9.6)
BenchmarkDotNet.Diagnostics.Windows (0.9.6)
BenchmarkDotNet (>= 0.9.6) - framework: >= net40, dnx451
BenchmarkDotNet (0.9.7)
BenchmarkDotNet.Diagnostics.Windows (0.9.7)
BenchmarkDotNet (>= 0.9.7) - framework: >= net40, dnx451
Microsoft.Diagnostics.Tracing.TraceEvent (>= 1.0.41) - framework: >= net40, dnx451
FParsec (1.0.2)
FSharp.Core (4.0.0.1)
Hopac (0.2.1)
FSharp.Core (>= 3.1.2.5)
Microsoft.Diagnostics.Tracing.TraceEvent (1.0.41) - framework: >= net40, dnx451
Newtonsoft.Json (8.0.3)
Suave (1.1.2)
@@ -16,23 +18,23 @@ GROUP Build
NUGET
remote: https://www.nuget.org/api/v2
specs:
FAKE (4.26.0)
FAKE (4.26)
FParsec (1.0.2)
FSharp.Compiler.Service (2.0.0.6)
FSharp.Formatting (2.14.2)
FSharp.Compiler.Service (2.0.0.6)
FSharpVSPowerTools.Core (>= 2.3.0 < 2.4.0)
FSharpVSPowerTools.Core (2.3.0)
FSharpVSPowerTools.Core (>= 2.3 < 2.4)
FSharpVSPowerTools.Core (2.3)
FSharp.Compiler.Service (>= 2.0.0.3)
Microsoft.Bcl (1.1.10) - framework: net10, net11, net20, net35, net40, net40
Microsoft.Bcl.Build (>= 1.0.14)
Microsoft.Bcl.Build (1.0.21) - import_targets: false, framework: net10, net11, net20, net35, net40, net40
Microsoft.Net.Http (2.2.29) - framework: net10, net11, net20, net35, net40, net40
Microsoft.Bcl (>= 1.1.10)
Microsoft.Bcl.Build (>= 1.0.14)
Octokit (0.19.0)
Octokit (0.19)
Microsoft.Net.Http
SourceLink.Fake (1.1.0)
SourceLink.Fake (1.1)
GITHUB
remote: fsharp/FAKE
specs:
@@ -42,7 +44,7 @@ GROUP Test
NUGET
remote: https://www.nuget.org/api/v2
specs:
FsCheck (2.4.0)
FsCheck (2.4)
FSharp.Core (>= 3.1.2.5)
FSharp.Core (4.0.0.1)
xunit (1.9.2)
@@ -1,6 +1,7 @@
#r "../../packages/Suave/lib/net40/Suave.dll"
#r "../../packages/Newtonsoft.Json/lib/net40/Newtonsoft.Json.dll"
#r "../../src/FSharp.Data.GraphQL/bin/Debug/FSharp.Data.GraphQL.dll"
#r "../../src/FSharp.Data.GraphQL/bin/Release/Hopac.dll"
#r "../../src/FSharp.Data.GraphQL/bin/Release/FSharp.Data.GraphQL.dll"
open System
@@ -86,15 +87,15 @@ open FSharp.Data.GraphQL.Execution
let EpisodeType = Define.Enum(
name = "Episode",
description = "One of the films in the Star Wars Trilogy",
options = [
options = [|
Define.EnumValue("NEWHOPE", Episode.NewHope, "Released in 1977.")
Define.EnumValue("EMPIRE", Episode.Empire, "Released in 1980.")
Define.EnumValue("JEDI", Episode.Jedi, "Released in 1983.")])
Define.EnumValue("JEDI", Episode.Jedi, "Released in 1983.") |])
let rec CharacterType = Define.Union(
name = "Character",
description = "A character in the Star Wars Trilogy",
options = [ HumanType; DroidType ],
options = [| HumanType; DroidType |],
resolveValue = (fun o ->
match o with
| Human h -> box h
@@ -108,7 +109,7 @@ and HumanType : ObjectDef<Human> = Define.Object<Human>(
name = "Human",
description = "A humanoid creature in the Star Wars universe.",
isTypeOf = (fun o -> o :? Human),
fieldsFn = fun () -> [
fieldsFn = fun () -> [|
Define.Field("id", String, "The id of the human.", fun _ h -> h.Id)
Define.Field("name", Nullable String, "The name of the human.", fun _ h -> h.Name)
Define.Field("friends", ListOf (Nullable CharacterType), "The friends of the human, or an empty list if they have none.",
@@ -117,27 +118,25 @@ and HumanType : ObjectDef<Human> = Define.Object<Human>(
|> List.map getCharacter
|> List.toSeq)
Define.Field("appearsIn", ListOf EpisodeType, "Which movies they appear in.", fun _ h -> upcast h.AppearsIn)
Define.Field("homePlanet", Nullable String, "The home planet of the human, or null if unknown.", fun _ h -> h.HomePlanet)
])
Define.Field("homePlanet", Nullable String, "The home planet of the human, or null if unknown.", fun _ h -> h.HomePlanet) |])
and DroidType = Define.Object<Droid>(
name = "Droid",
description = "A mechanical creature in the Star Wars universe.",
isTypeOf = (fun o -> o :? Droid),
fieldsFn = fun () -> [
fieldsFn = fun () -> [|
Define.Field("id", String, "The id of the droid.", fun _ d -> d.Id)
Define.Field("name", Nullable String, "The name of the Droid.", fun _ d -> d.Name)
Define.Field("friends", ListOf (Nullable CharacterType), "The friends of the Droid, or an empty list if they have none.",
fun ctx d -> d.Friends |> List.map getCharacter |> List.toSeq)
Define.Field("appearsIn", ListOf EpisodeType, "Which movies they appear in.", fun _ d -> upcast d.AppearsIn)
Define.Field("primaryFunction", Nullable String, "The primary function of the droid.", fun _ d -> d.PrimaryFunction)]
)
Define.Field("primaryFunction", Nullable String, "The primary function of the droid.", fun _ d -> d.PrimaryFunction) |])
let Query = Define.Object(
name = "Query",
fields = [
Define.Field("hero", Nullable HumanType, "Gets human hero", [ Define.Input("id", String) ], fun ctx () -> getHuman (ctx.Arg("id").Value))
Define.Field("droid", Nullable DroidType, "Gets droid", [ Define.Input("id", String) ], fun ctx () -> getDroid (ctx.Arg("id").Value))])
fields = [|
Define.Field("hero", Nullable HumanType, "Gets human hero", [| Define.Input("id", String) |], fun ctx () -> getHuman (ctx.Arg("id").Value))
Define.Field("droid", Nullable DroidType, "Gets droid", [| Define.Input("id", String) |], fun ctx () -> getDroid (ctx.Arg("id").Value)) |])
let schema = Schema(Query)
@@ -109,7 +109,7 @@
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1')">
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2')">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll</HintPath>
@@ -54,12 +54,12 @@ module Definitions =
let PageInfo = Define.Object<PageInfo>(
name = "PageInfo",
description = "Information about pagination in a connection.",
fields = [
fields = [|
Define.Field("hasNextPage", Boolean, "When paginating forwards, are there more items?", fun _ pageInfo -> pageInfo.HasNextPage)
Define.Field("hasPreviousPage", Boolean, "When paginating backwards, are there more items?", fun _ pageInfo -> pageInfo.HasPreviousPage)
Define.Field("startCursor", Nullable String, "When paginating backwards, the cursor to continue.", fun _ pageInfo -> pageInfo.StartCursor)
Define.Field("endCursor", Nullable String, "When paginating forwards, the cursor to continue.", fun _ pageInfo -> pageInfo.EndCursor)
])
|])
/// Converts existing output type defintion into an edge in a Relay connection.
/// <paramref name="nodeType"/> must not be a List.
@@ -70,9 +70,9 @@ module Definitions =
Define.Object<Edge<'Node>>(
name = n.Name + "Edge",
description = "An edge in a connection from an object to another object of type " + n.Name,
fields = [
fields = [|
Define.Field("cursor", String, "A cursor for use in pagination", fun _ edge -> edge.Cursor)
Define.Field("node", nodeType, "The item at the end of the edge. Must NOT be an enumerable collection.", fun _ edge -> edge.Node) ])
Define.Field("node", nodeType, "The item at the end of the edge. Must NOT be an enumerable collection.", fun _ edge -> edge.Node) |])
/// Converts existing output type definition into Relay-compatible connection.
/// <paramref name="nodeType"/> must not be a List.
@@ -81,23 +81,23 @@ module Definitions =
Define.Object<Connection<'Node>>(
name = n.Name + "Connection",
description = "A connection from an object to a list of objects of type " + n.Name,
fields = [
fields = [|
Define.Field("totalCount", Nullable Int, """A count of the total number of objects in this connection, ignoring pagination. This allows a client to fetch the first five objects by passing \"5\" as the argument to `first`, then fetch the total count so it could display \"5 of 83\", for example. In cases where we employ infinite scrolling or don't have an exact count of entries, this field will return `null`.""", fun _ conn -> conn.TotalCount)
Define.Field("pageInfo", PageInfo, "Information to aid in pagination.", fun _ conn -> conn.PageInfo)
Define.Field("edges", ListOf(EdgeOf nodeType), "Information to aid in pagination.", fun _ conn -> conn.Edges)])
Define.Field("edges", ListOf(EdgeOf nodeType), "Information to aid in pagination.", fun _ conn -> conn.Edges)|])
[<RequireQualifiedAccess>]
module Connection =
let forwardArgs = [
let forwardArgs = [|
Define.Input("first", Nullable Int)
Define.Input("after", Nullable String) ]
Define.Input("after", Nullable String) |]
let backwardArgs = [
let backwardArgs = [|
Define.Input("last", Nullable Int)
Define.Input("before", Nullable String) ]
Define.Input("before", Nullable String) |]
let allArgs = forwardArgs @ backwardArgs
let allArgs = Array.append forwardArgs backwardArgs
let ofArraySlice meta (SliceInfo args) (array: 't []) =
let startOffset, endOffset =
@@ -78,4 +78,25 @@
<Target Name="AfterBuild">
</Target>
-->
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.1' Or $(TargetFrameworkVersion) == 'v4.5.2' Or $(TargetFrameworkVersion) == 'v4.5.3' Or $(TargetFrameworkVersion) == 'v4.6' Or $(TargetFrameworkVersion) == 'v4.6.1' Or $(TargetFrameworkVersion) == 'v4.6.2')">
<ItemGroup>
<Reference Include="Hopac.Core">
<HintPath>..\..\packages\Hopac\lib\net45\Hopac.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
<Reference Include="Hopac.Platform">
<HintPath>..\..\packages\Hopac\lib\net45\Hopac.Platform.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
<Reference Include="Hopac">
<HintPath>..\..\packages\Hopac\lib\net45\Hopac.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project>
@@ -60,14 +60,14 @@ module GlobalId =
name = "node",
typedef = Nullable nodeDef,
description = "Fetches an object given its ID",
args = [ Define.Input("id", Nullable ID, description = "Identifier of an object") ],
args = [| Define.Input("id", Nullable ID, description = "Identifier of an object") |],
resolve = fun ctx value ->
let id = ctx.Arg("id").Value
resolve ctx value id)
static member Node (possibleTypes: unit -> ObjectDef list) = Define.Interface(
name = "Node",
description = "An object that can be uniquely identified by its id",
fields = [Define.Field("id", ID)],
fields = [| Define.Field("id", ID) |],
resolveType = resolveTypeFun possibleTypes)
@@ -0,0 +1 @@
Hopac
@@ -130,13 +130,13 @@ and SchemaDefintion = {
and ObjectTypeDefinition = {
Name: string
Interfaces: string list
Fields: FieldDefinition list
Interfaces: string []
Fields: FieldDefinition []
}
and FieldDefinition = {
Name: string
Arguments: InputValueDefinition list
Arguments: InputValueDefinition []
Type: InputType
}
@@ -148,22 +148,22 @@ and InputValueDefinition = {
and InterfaceTypeDefinition = {
Name: string
Fields: FieldDefinition list
Fields: FieldDefinition []
}
and UnionTypeDefinition = {
Name: string
Types: string list
Types: string []
}
and EnumTypeDefinition = {
Name: string
Values: string list
Values: string []
}
and InputObjectTypeDefinition = {
Name: string
Fields: InputValueDefinition list
Fields: InputValueDefinition []
}
and TypeDefinition =
Oops, something went wrong.

0 comments on commit ebebebe

Please sign in to comment.