fragment-alpha-sdk 0.1.0 → 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 -9
- 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
@@ -7,13 +7,13 @@ require 'json'
|
|
7
7
|
require 'graphql/client'
|
8
8
|
require 'graphql/client/http'
|
9
9
|
require 'sorbet-runtime'
|
10
|
-
require 'pry'
|
11
10
|
|
11
|
+
# A support module for the client
|
12
12
|
module FragmentGraphQl
|
13
13
|
extend T::Sig
|
14
14
|
http = GraphQL::Client.const_get(:HTTP).new('https://api.fragment.dev/graphql') do
|
15
15
|
extend T::Sig
|
16
|
-
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]) }
|
17
17
|
def headers(context)
|
18
18
|
{ 'Authorization' => 'Bearer %s' % context[:access_token] }
|
19
19
|
end
|
@@ -21,14 +21,11 @@ module FragmentGraphQl
|
|
21
21
|
|
22
22
|
Schema = T.let(GraphQL::Client.load_schema("#{__dir__}/fragment.schema.json"), T.untyped)
|
23
23
|
|
24
|
-
|
25
|
-
pry
|
26
|
-
|
27
|
-
Client = T.let(GraphQL::Client.new(schema: Schema, execute: RDoc::Attr), GraphQL::Client)
|
24
|
+
Client = T.let(GraphQL::Client.new(schema: Schema, execute: http), GraphQL::Client)
|
28
25
|
|
29
26
|
Queries = T.let(Client.parse(
|
30
|
-
|
31
|
-
|
27
|
+
File.open("#{__dir__}/queries.graphql").read
|
28
|
+
), T.untyped)
|
32
29
|
end
|
33
30
|
|
34
31
|
# A client for Fragment
|
@@ -53,7 +50,7 @@ class FragmentClient
|
|
53
50
|
end
|
54
51
|
end
|
55
52
|
|
56
|
-
sig {params(query: T.untyped, variables: T.untyped).returns(T.untyped)}
|
53
|
+
sig { params(query: T.untyped, variables: T.untyped).returns(T.untyped) }
|
57
54
|
def query(query, variables)
|
58
55
|
FragmentGraphQl::Client.query(query, variables: variables, context: { access_token: @token })
|
59
56
|
end
|