FSharp.Data.GraphQL
FSharp.Data.GraphQL is a client and server implementation of Facebook's GraphQL query language.
It's a standard created for building web service APIs and a runtime for defining those APIs in statically typed, well formed way. The core idea is to define web service in context of its capabilities in oposition to routees known from existing RESTful APIs. Capabilities are defined in form of GraphQL schema and describe all operations and data allowed to be requested by the client, without fragmenting it into particular routes.
The FSharp.Data.GraphQL library can be installed from NuGet on the server or a client:
1: 2: |
|
Quick start
To use FSharp.Data.GraphQL on the server side, first define some data working as a source:
1: 2: 3: 4: |
|
Then expose it through the schema - GraphQL language defines it's own type system, that can be integrated with any other programming language:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: |
|
With schema create we are now able to respond to any incoming GraphQL queries:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: |
|
More examples
For more examples, clone FSharp.Data.GraphQL github repository and see the samples folder. There, your can find:
- A mandatory Star Wars schema introduction using GraphiQL client.
- An example using RelayJS data structures (which this library supports).
- A client example, using type providers to operate on any GraphQL schema available - worth noticing: it's compatbile with Fable compiler!
- A fully fledged ToDo application, where FSharp.Data.GraphQL is used for both server and client.
Contributing and copyright
The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. If you're adding a new public API, please also consider adding samples that can be turned into a documentation. You might also want to read the library design notes to understand how it works.
The library is available under Public Domain license, which allows modification and redistribution for both commercial and non-commercial purposes. For more information see the License file in the GitHub repository.
{FirstName: string;
LastName: string;}
Full name: index.Person
val string : value:'T -> string
Full name: Microsoft.FSharp.Core.Operators.string
--------------------
type string = System.String
Full name: Microsoft.FSharp.Core.string
Full name: index.people
val Person : obj
Full name: index.Person
--------------------
type Person =
{FirstName: string;
LastName: string;}
Full name: index.Person
from Microsoft.FSharp.Core
Full name: index.QueryRoot
Full name: index.schema
Full name: index.query
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.async
Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printf