-
Notifications
You must be signed in to change notification settings - Fork 74
/
github_access.fsx
26 lines (19 loc) · 1.27 KB
/
github_access.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Uncomment those to use build script client assembly using netstandard2.0
//#r "../../bin/FSharp.Data.GraphQL.Shared/netstandard2.0/FSharp.Data.GraphQL.Shared.dll"
//#r "../../bin/FSharp.Data.GraphQL.Client/netstandard2.0/FSharp.Data.GraphQL.Client.dll"
//Uncomment those to use dotnet build command for the client assembly using netstandard2.0
#r "../../src/FSharp.Data.GraphQL.Shared/bin/Debug/netstandard2.0/FSharp.Data.GraphQL.Shared.dll"
#r "../../src/FSharp.Data.GraphQL.Client/bin/Debug/netstandard2.0/FSharp.Data.GraphQL.Client.dll"
open FSharp.Data.GraphQL
// Some GraphQL API's gives access to their schema via GET method, whithout need to anthenticate via headers.
// The provider automatically tries to get the schema via GET method first. If it does not work,
// The classical way via POST is done.
type MyProvider = GraphQLProvider<"github_schema.json">
let operation = MyProvider.Operation<"""query q { viewer { login } }"""> ()
let headers = HttpHeaders.ofFile "github_authorization_headers.headerfile"
let run () =
// Dispose runtime context after using it.
use runtimeContext = MyProvider.GetContext (serverUrl = "https://api.github.com/graphql", httpHeaders = headers)
let result = operation.Run (runtimeContext)
printfn "Data: %A\n" result.Data
run ()