graphql-client-aws 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/client/aws.rb +35 -21
- metadata +46 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c8c0ce38970f8f7addaa22a17f46af695aad6bce4158f1859dd900ac87f297c
|
4
|
+
data.tar.gz: 2b614847dbeac689a738a7257b00b539d8b88a6d68059dfbe30517a81aec9a35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e55e91e02959aab3ba1716cd8fe243e81bfc9c9d40afa6116d265d80fbeeaa3ca0dc7ab401a73148dc8621f9dd98d860f6717e9ddbdfbdab5af7d0881ba0ea6
|
7
|
+
data.tar.gz: f7c0854f90af351cb1e3fe83c0e5e60d42b1e46661cbda0bea7bee5549e9c3bd88e8476a2429d579a6382281f46bcd95817126c518191d4437a1903c4b8d02ce
|
data/lib/graphql/client/aws.rb
CHANGED
@@ -7,37 +7,51 @@ module GraphQL
|
|
7
7
|
class Client
|
8
8
|
class Aws < GraphQL::Client::HTTP
|
9
9
|
def initialize(uri, **opts, &block)
|
10
|
-
appsync_opts = opts.merge(service: 'appsync')
|
11
|
-
@signer = ::Aws::Sigv4::Signer.new(appsync_opts)
|
12
10
|
if block_given?
|
13
11
|
super(uri, &block)
|
14
12
|
else
|
15
13
|
super(uri)
|
16
14
|
end
|
15
|
+
appsync_signer_option = opts.merge(service: 'appsync')
|
16
|
+
@signer = ::Aws::Sigv4::Signer.new(appsync_signer_option)
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
def execute(document:, operation_name: nil, variables: {}, context: {})
|
20
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
21
|
+
|
22
|
+
request['Accept'] = 'application/json'
|
23
|
+
headers(context).each { |name, value| request[name] = value }
|
24
|
+
|
25
|
+
request.body = build_body(document, operation_name, variables)
|
26
|
+
|
27
|
+
request = sign!(request)
|
28
|
+
|
29
|
+
response = connection.request(request)
|
30
|
+
|
31
|
+
case response
|
32
|
+
when Net::HTTPOK, Net::HTTPBadRequest
|
33
|
+
JSON.parse(response.body)
|
34
|
+
else
|
35
|
+
{ 'errors' => [{ 'message' => "#{response.code} #{response.message}" }] }
|
24
36
|
end
|
25
37
|
end
|
26
|
-
end
|
27
38
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
def build_body(document, operation_name, variables)
|
40
|
+
body = { 'query' => document.to_query_string }
|
41
|
+
body['variables'] = variables if variables.any?
|
42
|
+
body['operationName'] = operation_name if operation_name
|
43
|
+
JSON.generate(body)
|
44
|
+
end
|
45
|
+
|
46
|
+
def sign!(request)
|
47
|
+
signature = @signer.sign_request(http_method: request.method, url: uri, body: request.body)
|
48
|
+
request['Host'] = signature.headers['Host']
|
49
|
+
request['X-Amz-Date'] = signature.headers['x-amz-date']
|
50
|
+
request['X-Amz-Security-Token'] = signature.headers['x-amz-security-token']
|
51
|
+
request['X-Amz-Content-Sha256']= signature.headers['x-amz-content-sha256']
|
52
|
+
request['Authorization'] = signature.headers['authorization']
|
53
|
+
request['Content-Type'] = 'application/graphql'
|
54
|
+
request
|
41
55
|
end
|
42
56
|
end
|
43
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-client-aws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sonodar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sigv4
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0.14'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hashdiff
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.0.beta1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0.beta1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,8 +108,36 @@ dependencies:
|
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: vcr
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
97
139
|
description: A Ruby library for declaring, composing and executing GraphQL queries
|
98
|
-
for AWS AppSync
|
140
|
+
for AWS AppSync IAM Authorization
|
99
141
|
email: ryoheisonoda@outlook.com
|
100
142
|
executables: []
|
101
143
|
extensions: []
|
@@ -126,5 +168,5 @@ requirements: []
|
|
126
168
|
rubygems_version: 3.0.4
|
127
169
|
signing_key:
|
128
170
|
specification_version: 4
|
129
|
-
summary: GraphQL Client for AWS AppSync
|
171
|
+
summary: GraphQL Client Adapter for AWS AppSync IAM Authorization
|
130
172
|
test_files: []
|