graphql-repl 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/graphql-repl +5 -1
- data/lib/graphql/repl.rb +4 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c8de9d35a4c32aa55a138dec38219f8d5aa16eb
|
4
|
+
data.tar.gz: f800d2bd2b835c88e0ff641e55e29bf1ce9c8dd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f93e0d9e3e2f5622a5386994409675b495ef9b6603796970c4699391c77d82f4111ebaa1a4dbf34eeee3eba9c93da847b7219c0a0074693b7e078080bef04cf
|
7
|
+
data.tar.gz: 1763fc64e91256e6fc299ac39f38625e00dcff416999998326974e1571ade8cd1a1dcbe9d6eeac4bafe03a2bec9f37ef924ff469ce04483d5240077c09487785
|
data/bin/graphql-repl
CHANGED
@@ -15,9 +15,13 @@ OptionParser.new do |opts|
|
|
15
15
|
opts.on("-a=", "--authorization=", "Set Authorization HTTP header") do |v|
|
16
16
|
options[:headers]["Authorization"] = v
|
17
17
|
end
|
18
|
+
|
19
|
+
opts.on("-n", "--netrc", "Read ~/.netrc credentials") do |v|
|
20
|
+
options[:netrc] = true
|
21
|
+
end
|
18
22
|
end.parse!
|
19
23
|
|
20
|
-
repl = GraphQL::REPL.new(ARGV[0], options
|
24
|
+
repl = GraphQL::REPL.new(ARGV[0], **options)
|
21
25
|
|
22
26
|
Readline.completion_append_character = ""
|
23
27
|
Readline.completion_proc = proc { |s| repl.completions(s) }
|
data/lib/graphql/repl.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
require 'graphql'
|
2
2
|
require 'json'
|
3
3
|
require 'net/http'
|
4
|
+
require 'netrc'
|
4
5
|
|
5
6
|
module GraphQL
|
6
7
|
class REPL
|
7
8
|
IntrospectionDocument = GraphQL.parse(GraphQL::Introspection::INTROSPECTION_QUERY)
|
8
9
|
|
9
|
-
def initialize(uri, headers
|
10
|
+
def initialize(uri, username: nil, password: nil, netrc: false, headers: {})
|
10
11
|
@uri = URI.parse(uri)
|
11
12
|
@headers = headers
|
13
|
+
@username, @password = Netrc.read[@uri.hostname] if netrc
|
12
14
|
|
13
15
|
@connection = Net::HTTP.new(@uri.host, @uri.port).tap do |client|
|
14
16
|
client.use_ssl = @uri.scheme == "https"
|
@@ -19,6 +21,7 @@ module GraphQL
|
|
19
21
|
|
20
22
|
def request(query)
|
21
23
|
request = Net::HTTP::Post.new(@uri.request_uri)
|
24
|
+
request.basic_auth(@username, @password)
|
22
25
|
request["Accept"] = "application/json"
|
23
26
|
request["Content-Type"] = "application/json"
|
24
27
|
@headers.each { |k, v| request[k] = v }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-repl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Peek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: netrc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.11'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.11'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: minitest
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -83,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
97
|
version: '0'
|
84
98
|
requirements: []
|
85
99
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
100
|
+
rubygems_version: 2.6.13
|
87
101
|
signing_key:
|
88
102
|
specification_version: 4
|
89
103
|
summary: GraphQL REPL
|