fragment-alpha-sdk 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fragment_client.rb +6 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cf03179626f6c1922a1ee0f77cd7a04ede4d909ca21e54fb40b32d0bb0dca86
|
4
|
+
data.tar.gz: 25c7dd03d7dffaa64097c437489aef3db649641fc41e27f150f0b0ff7ab82e6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65d2f4e9deba146534d24d3d8b2ecad0f2c92231c6a54e098bc1e595c5da4fee41140dfe1252e24e683b6e6de647c09e933a9561f448c7a53baa70869313d0b7
|
7
|
+
data.tar.gz: 9b1d95a0e3639930974482a6cdc7fa01822415db8a6103f2928e5394e2a68ff791a10bea6593d886969724850c46f12f517c35f52f4053353068a6a5bc8e968d
|
data/lib/fragment_client.rb
CHANGED
@@ -8,11 +8,12 @@ require 'graphql/client'
|
|
8
8
|
require 'graphql/client/http'
|
9
9
|
require 'sorbet-runtime'
|
10
10
|
|
11
|
+
# A support module for the client
|
11
12
|
module FragmentGraphQl
|
12
13
|
extend T::Sig
|
13
14
|
http = GraphQL::Client.const_get(:HTTP).new('https://api.fragment.dev/graphql') do
|
14
15
|
extend T::Sig
|
15
|
-
sig {params(context: T.untyped).returns(T::Hash[T.untyped, T.untyped])}
|
16
|
+
sig { params(context: T.untyped).returns(T::Hash[T.untyped, T.untyped]) }
|
16
17
|
def headers(context)
|
17
18
|
{ 'Authorization' => 'Bearer %s' % context[:access_token] }
|
18
19
|
end
|
@@ -20,11 +21,11 @@ module FragmentGraphQl
|
|
20
21
|
|
21
22
|
Schema = T.let(GraphQL::Client.load_schema("#{__dir__}/fragment.schema.json"), T.untyped)
|
22
23
|
|
23
|
-
Client = T.let(GraphQL::Client.new(schema: Schema, execute:
|
24
|
+
Client = T.let(GraphQL::Client.new(schema: Schema, execute: http), GraphQL::Client)
|
24
25
|
|
25
26
|
Queries = T.let(Client.parse(
|
26
|
-
|
27
|
-
|
27
|
+
File.open("#{__dir__}/queries.graphql").read
|
28
|
+
), T.untyped)
|
28
29
|
end
|
29
30
|
|
30
31
|
# A client for Fragment
|
@@ -49,7 +50,7 @@ class FragmentClient
|
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
52
|
-
sig {params(query: T.untyped, variables: T.untyped).returns(T.untyped)}
|
53
|
+
sig { params(query: T.untyped, variables: T.untyped).returns(T.untyped) }
|
53
54
|
def query(query, variables)
|
54
55
|
FragmentGraphQl::Client.query(query, variables: variables, context: { access_token: @token })
|
55
56
|
end
|