graphql 1.12.5 → 1.12.6
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.
Potentially problematic release.
This version of graphql might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/graphql.rb +3 -1
- data/lib/graphql/language.rb +1 -0
- data/lib/graphql/language/cache.rb +37 -0
- data/lib/graphql/language/parser.rb +15 -5
- data/lib/graphql/language/parser.y +15 -5
- data/lib/graphql/pagination/connection.rb +6 -1
- data/lib/graphql/pagination/connections.rb +1 -0
- data/lib/graphql/pagination/relation_connection.rb +5 -1
- data/lib/graphql/railtie.rb +9 -1
- data/lib/graphql/schema/field/connection_extension.rb +1 -0
- data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +2 -2
- data/lib/graphql/tracing/active_support_notifications_tracing.rb +2 -1
- data/lib/graphql/types/relay/connection_behaviors.rb +25 -3
- data/lib/graphql/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebd2e71516a89475e1617ee60250d4d88f6d3743090ae8010e6918ce425a71fc
|
4
|
+
data.tar.gz: c0577dd5aac0765abf748f9ba86b3a3a814658abba7a2285b4e0d929959de50f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 832d9464fe69bacc19d4a8715e5d2869d8ff15a4c1c34316d9c092b295e2175ac4f7a746a736773914ac4789478baa28a1f451c57cee732346901d5e4e10e430
|
7
|
+
data.tar.gz: 84f4918a0473bf07c657ca39392866ece0a36ca592272f85580417882b762e7210cd6404ee1671ad651ac7608acdb0103a4a262253e48ccc9b75be2804c5caf4
|
data/lib/graphql.rb
CHANGED
@@ -4,7 +4,6 @@ require "json"
|
|
4
4
|
require "set"
|
5
5
|
require "singleton"
|
6
6
|
require "forwardable"
|
7
|
-
require_relative "./graphql/railtie" if defined? Rails::Railtie
|
8
7
|
|
9
8
|
module GraphQL
|
10
9
|
# forwards-compat for argument handling
|
@@ -103,6 +102,9 @@ require "graphql/scalar_type"
|
|
103
102
|
require "graphql/name_validator"
|
104
103
|
|
105
104
|
require "graphql/language"
|
105
|
+
|
106
|
+
require_relative "./graphql/railtie" if defined? Rails::Railtie
|
107
|
+
|
106
108
|
require "graphql/analysis"
|
107
109
|
require "graphql/tracing"
|
108
110
|
require "graphql/dig"
|
data/lib/graphql/language.rb
CHANGED
@@ -6,6 +6,7 @@ require "graphql/language/document_from_schema_definition"
|
|
6
6
|
require "graphql/language/generation"
|
7
7
|
require "graphql/language/lexer"
|
8
8
|
require "graphql/language/nodes"
|
9
|
+
require "graphql/language/cache"
|
9
10
|
require "graphql/language/parser"
|
10
11
|
require "graphql/language/token"
|
11
12
|
require "graphql/language/visitor"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'graphql/version'
|
4
|
+
require 'digest/sha2'
|
5
|
+
|
6
|
+
module GraphQL
|
7
|
+
module Language
|
8
|
+
class Cache
|
9
|
+
def initialize(path)
|
10
|
+
@path = path
|
11
|
+
end
|
12
|
+
|
13
|
+
DIGEST = Digest::SHA256.new << GraphQL::VERSION
|
14
|
+
def fetch(filename)
|
15
|
+
hash = DIGEST.dup << filename
|
16
|
+
begin
|
17
|
+
hash << File.mtime(filename).to_i.to_s
|
18
|
+
rescue SystemCallError
|
19
|
+
return yield
|
20
|
+
end
|
21
|
+
cache_path = @path.join(hash.to_s)
|
22
|
+
|
23
|
+
if cache_path.exist?
|
24
|
+
Marshal.load(cache_path.read)
|
25
|
+
else
|
26
|
+
payload = yield
|
27
|
+
tmp_path = "#{cache_path}.#{rand}"
|
28
|
+
|
29
|
+
@path.mkpath
|
30
|
+
File.binwrite(tmp_path, Marshal.dump(payload))
|
31
|
+
File.rename(tmp_path, cache_path.to_s)
|
32
|
+
payload
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -41,12 +41,22 @@ def parse_document
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
class << self
|
45
|
+
attr_accessor :cache
|
46
|
+
|
47
|
+
def parse(query_string, filename: nil, tracer: GraphQL::Tracing::NullTracer)
|
48
|
+
new(query_string, filename: filename, tracer: tracer).parse_document
|
49
|
+
end
|
47
50
|
|
48
|
-
def
|
49
|
-
|
51
|
+
def parse_file(filename, tracer: GraphQL::Tracing::NullTracer)
|
52
|
+
if cache
|
53
|
+
cache.fetch(filename) do
|
54
|
+
parse(File.read(filename), filename: filename, tracer: tracer)
|
55
|
+
end
|
56
|
+
else
|
57
|
+
parse(File.read(filename), filename: filename, tracer: tracer)
|
58
|
+
end
|
59
|
+
end
|
50
60
|
end
|
51
61
|
|
52
62
|
private
|
@@ -462,12 +462,22 @@ def parse_document
|
|
462
462
|
end
|
463
463
|
end
|
464
464
|
|
465
|
-
|
466
|
-
|
467
|
-
|
465
|
+
class << self
|
466
|
+
attr_accessor :cache
|
467
|
+
|
468
|
+
def parse(query_string, filename: nil, tracer: GraphQL::Tracing::NullTracer)
|
469
|
+
new(query_string, filename: filename, tracer: tracer).parse_document
|
470
|
+
end
|
468
471
|
|
469
|
-
def
|
470
|
-
|
472
|
+
def parse_file(filename, tracer: GraphQL::Tracing::NullTracer)
|
473
|
+
if cache
|
474
|
+
cache.fetch(filename) do
|
475
|
+
parse(File.read(filename), filename: filename, tracer: tracer)
|
476
|
+
end
|
477
|
+
else
|
478
|
+
parse(File.read(filename), filename: filename, tracer: tracer)
|
479
|
+
end
|
480
|
+
end
|
471
481
|
end
|
472
482
|
|
473
483
|
private
|
@@ -45,6 +45,9 @@ module GraphQL
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
# @return [Hash<Symbol => Object>] The field arguments from the field that returned this connection
|
49
|
+
attr_accessor :arguments
|
50
|
+
|
48
51
|
# @param items [Object] some unpaginated collection item, like an `Array` or `ActiveRecord::Relation`
|
49
52
|
# @param context [Query::Context]
|
50
53
|
# @param parent [Object] The object this collection belongs to
|
@@ -52,8 +55,9 @@ module GraphQL
|
|
52
55
|
# @param after [String, nil] A cursor for pagination, if the client provided one
|
53
56
|
# @param last [Integer, nil] Limit parameter from the client, if provided
|
54
57
|
# @param before [String, nil] A cursor for pagination, if the client provided one.
|
58
|
+
# @param arguments [Hash] The arguments to the field that returned the collection wrapped by this connection
|
55
59
|
# @param max_page_size [Integer, nil] A configured value to cap the result size. Applied as `first` if neither first or last are given.
|
56
|
-
def initialize(items, parent: nil, field: nil, context: nil, first: nil, after: nil, max_page_size: :not_given, last: nil, before: nil, edge_class: nil)
|
60
|
+
def initialize(items, parent: nil, field: nil, context: nil, first: nil, after: nil, max_page_size: :not_given, last: nil, before: nil, edge_class: nil, arguments: nil)
|
57
61
|
@items = items
|
58
62
|
@parent = parent
|
59
63
|
@context = context
|
@@ -62,6 +66,7 @@ module GraphQL
|
|
62
66
|
@after_value = after
|
63
67
|
@last_value = last
|
64
68
|
@before_value = before
|
69
|
+
@arguments = arguments
|
65
70
|
@edge_class = edge_class || self.class::Edge
|
66
71
|
# This is only true if the object was _initialized_ with an override
|
67
72
|
# or if one is assigned later.
|
@@ -32,7 +32,11 @@ module GraphQL
|
|
32
32
|
@has_next_page = if before_offset && before_offset > 0
|
33
33
|
true
|
34
34
|
elsif first
|
35
|
-
|
35
|
+
if @nodes && @nodes.count < first
|
36
|
+
false
|
37
|
+
else
|
38
|
+
relation_count(set_limit(sliced_nodes, first + 1)) == first + 1
|
39
|
+
end
|
36
40
|
else
|
37
41
|
false
|
38
42
|
end
|
data/lib/graphql/railtie.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
3
|
module GraphQL
|
5
4
|
class Railtie < Rails::Railtie
|
5
|
+
config.before_configuration do
|
6
|
+
# Bootsnap compile cache has similar expiration properties,
|
7
|
+
# so we assume that if the user has bootsnap setup it's ok
|
8
|
+
# to piggy back on it.
|
9
|
+
if ::Object.const_defined?("Bootsnap::CompileCache::ISeq") && Bootsnap::CompileCache::ISeq.cache_dir
|
10
|
+
Language::Parser.cache ||= Language::Cache.new(Pathname.new(Bootsnap::CompileCache::ISeq.cache_dir).join('graphql'))
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
6
14
|
rake_tasks do
|
7
15
|
# Defer this so that you only need the `parser` gem when you _run_ the upgrader
|
8
16
|
def load_upgraders
|
@@ -42,6 +42,7 @@ module GraphQL
|
|
42
42
|
value.after_value ||= original_arguments[:after]
|
43
43
|
value.last_value ||= original_arguments[:last]
|
44
44
|
value.before_value ||= original_arguments[:before]
|
45
|
+
value.arguments ||= original_arguments
|
45
46
|
value.field ||= field
|
46
47
|
if field.has_max_page_size? && !value.has_max_page_size_override?
|
47
48
|
value.max_page_size = field.max_page_size
|
@@ -29,8 +29,8 @@ module GraphQL
|
|
29
29
|
context.directive_definition.arguments
|
30
30
|
when GraphQL::Language::Nodes::InputObject
|
31
31
|
arg_type = context.argument_definition.type.unwrap
|
32
|
-
if arg_type.
|
33
|
-
arguments = arg_type.
|
32
|
+
if arg_type.kind.input_object?
|
33
|
+
arguments = arg_type.arguments
|
34
34
|
else
|
35
35
|
# This is some kind of error
|
36
36
|
nil
|
@@ -3,8 +3,9 @@
|
|
3
3
|
module GraphQL
|
4
4
|
module Tracing
|
5
5
|
# This implementation forwards events to ActiveSupport::Notifications
|
6
|
-
# with a `graphql
|
6
|
+
# with a `graphql` suffix.
|
7
7
|
#
|
8
|
+
# @see KEYS for event names
|
8
9
|
module ActiveSupportNotificationsTracing
|
9
10
|
# A cache of frequently-used keys to avoid needless string allocations
|
10
11
|
KEYS = {
|
@@ -12,6 +12,8 @@ module GraphQL
|
|
12
12
|
child_class.extend(Relay::DefaultRelay)
|
13
13
|
child_class.default_relay(true)
|
14
14
|
child_class.node_nullable(true)
|
15
|
+
child_class.edges_nullable(true)
|
16
|
+
child_class.edge_nullable(true)
|
15
17
|
add_page_info_field(child_class)
|
16
18
|
end
|
17
19
|
|
@@ -32,7 +34,7 @@ module GraphQL
|
|
32
34
|
# It's called when you subclass this base connection, trying to use the
|
33
35
|
# class name to set defaults. You can call it again in the class definition
|
34
36
|
# to override the default (or provide a value, if the default lookup failed).
|
35
|
-
def edge_type(edge_type_class, edge_class: GraphQL::Relay::Edge, node_type: edge_type_class.node_type, nodes_field: true, node_nullable: self.node_nullable)
|
37
|
+
def edge_type(edge_type_class, edge_class: GraphQL::Relay::Edge, node_type: edge_type_class.node_type, nodes_field: true, node_nullable: self.node_nullable, edges_nullable: self.edges_nullable, edge_nullable: self.edge_nullable)
|
36
38
|
# Set this connection's graphql name
|
37
39
|
node_type_name = node_type.graphql_name
|
38
40
|
|
@@ -40,8 +42,8 @@ module GraphQL
|
|
40
42
|
@edge_type = edge_type_class
|
41
43
|
@edge_class = edge_class
|
42
44
|
|
43
|
-
field :edges, [edge_type_class, null:
|
44
|
-
null:
|
45
|
+
field :edges, [edge_type_class, null: edge_nullable],
|
46
|
+
null: edges_nullable,
|
45
47
|
description: "A list of edges.",
|
46
48
|
legacy_edge_class: edge_class, # This is used by the old runtime only, for EdgesInstrumentation
|
47
49
|
connection: false
|
@@ -83,6 +85,26 @@ module GraphQL
|
|
83
85
|
end
|
84
86
|
end
|
85
87
|
|
88
|
+
# Set the default `edges_nullable` for this class and its child classes. (Defaults to `true`.)
|
89
|
+
# Use `edges_nullable(false)` in your base class to make non-null `edges` fields.
|
90
|
+
def edges_nullable(new_value = nil)
|
91
|
+
if new_value.nil?
|
92
|
+
@edges_nullable || superclass.edges_nullable
|
93
|
+
else
|
94
|
+
@edges_nullable ||= new_value
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Set the default `edge_nullable` for this class and its child classes. (Defaults to `true`.)
|
99
|
+
# Use `edge_nullable(false)` in your base class to make non-null `edge` fields.
|
100
|
+
def edge_nullable(new_value = nil)
|
101
|
+
if new_value.nil?
|
102
|
+
@edge_nullable || superclass.edge_nullable
|
103
|
+
else
|
104
|
+
@edge_nullable ||= new_value
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
86
108
|
private
|
87
109
|
|
88
110
|
def define_nodes_field(nullable)
|
data/lib/graphql/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.12.
|
4
|
+
version: 1.12.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -414,6 +414,7 @@ files:
|
|
414
414
|
- lib/graphql/invalid_null_error.rb
|
415
415
|
- lib/graphql/language.rb
|
416
416
|
- lib/graphql/language/block_string.rb
|
417
|
+
- lib/graphql/language/cache.rb
|
417
418
|
- lib/graphql/language/definition_slice.rb
|
418
419
|
- lib/graphql/language/document_from_schema_definition.rb
|
419
420
|
- lib/graphql/language/generation.rb
|