graphql 1.8.0.pre11 → 1.8.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/lib/generators/graphql/templates/schema.erb +1 -1
- data/lib/graphql/function.rb +2 -0
- data/lib/graphql/railtie.rb +1 -1
- data/lib/graphql/schema.rb +1 -0
- data/lib/graphql/schema/argument.rb +3 -2
- data/lib/graphql/schema/build_from_definition.rb +1 -1
- data/lib/graphql/schema/field.rb +96 -49
- data/lib/graphql/schema/interface.rb +21 -3
- data/lib/graphql/schema/list.rb +4 -0
- data/lib/graphql/schema/member/accepts_definition.rb +2 -2
- data/lib/graphql/schema/member/base_dsl_methods.rb +4 -0
- data/lib/graphql/schema/member/build_type.rb +4 -2
- data/lib/graphql/schema/member/has_fields.rb +1 -8
- data/lib/graphql/schema/mutation.rb +19 -88
- data/lib/graphql/schema/non_null.rb +4 -0
- data/lib/graphql/schema/object.rb +1 -1
- data/lib/graphql/schema/relay_classic_mutation.rb +14 -15
- data/lib/graphql/schema/resolver.rb +122 -0
- data/lib/graphql/subscriptions/instrumentation.rb +5 -1
- data/lib/graphql/subscriptions/serialize.rb +2 -0
- data/lib/graphql/tracing/new_relic_tracing.rb +26 -0
- data/lib/graphql/version.rb +1 -1
- data/readme.md +1 -1
- data/spec/generators/graphql/install_generator_spec.rb +1 -1
- data/spec/graphql/relay/mutation_spec.rb +5 -3
- data/spec/graphql/schema/build_from_definition_spec.rb +1 -1
- data/spec/graphql/schema/field_spec.rb +7 -24
- data/spec/graphql/schema/interface_spec.rb +25 -0
- data/spec/graphql/schema/member/accepts_definition_spec.rb +22 -0
- data/spec/graphql/schema/member/build_type_spec.rb +17 -0
- data/spec/graphql/schema/mutation_spec.rb +15 -14
- data/spec/graphql/schema/resolver_spec.rb +131 -0
- data/spec/graphql/subscriptions_spec.rb +267 -205
- data/spec/graphql/tracing/new_relic_tracing_spec.rb +47 -0
- data/spec/support/jazz.rb +6 -1
- data/spec/support/new_relic.rb +24 -0
- data/spec/support/star_trek/schema.rb +2 -2
- data/spec/support/star_wars/schema.rb +1 -2
- metadata +13 -4
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe GraphQL::Tracing::NewRelicTracing do
|
5
|
+
module NewRelicTest
|
6
|
+
class Query < GraphQL::Schema::Object
|
7
|
+
field :int, Integer, null: false
|
8
|
+
|
9
|
+
def int
|
10
|
+
1
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class SchemaWithoutTransactionName < GraphQL::Schema
|
15
|
+
query(Query)
|
16
|
+
use(GraphQL::Tracing::NewRelicTracing)
|
17
|
+
end
|
18
|
+
|
19
|
+
class SchemaWithTransactionName < GraphQL::Schema
|
20
|
+
query(Query)
|
21
|
+
use(GraphQL::Tracing::NewRelicTracing, set_transaction_name: true)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
before do
|
26
|
+
NewRelic.clear_all
|
27
|
+
end
|
28
|
+
|
29
|
+
it "can leave the transaction name in place" do
|
30
|
+
NewRelicTest::SchemaWithoutTransactionName.execute "query X { int }"
|
31
|
+
assert_equal [], NewRelic::TRANSACTION_NAMES
|
32
|
+
end
|
33
|
+
|
34
|
+
it "can override the transaction name" do
|
35
|
+
NewRelicTest::SchemaWithTransactionName.execute "query X { int }"
|
36
|
+
assert_equal ["GraphQL/query.X"], NewRelic::TRANSACTION_NAMES
|
37
|
+
end
|
38
|
+
|
39
|
+
it "can override the transaction name per query" do
|
40
|
+
# Override with `false`
|
41
|
+
NewRelicTest::SchemaWithTransactionName.execute "{ int }", context: { set_new_relic_transaction_name: false }
|
42
|
+
assert_equal [], NewRelic::TRANSACTION_NAMES
|
43
|
+
# Override with `true`
|
44
|
+
NewRelicTest::SchemaWithoutTransactionName.execute "{ int }", context: { set_new_relic_transaction_name: true }
|
45
|
+
assert_equal ["GraphQL/query.anonymous"], NewRelic::TRANSACTION_NAMES
|
46
|
+
end
|
47
|
+
end
|
data/spec/support/jazz.rb
CHANGED
@@ -133,7 +133,12 @@ module Jazz
|
|
133
133
|
module GloballyIdentifiableType
|
134
134
|
include BaseInterface
|
135
135
|
description "A fetchable object in the system"
|
136
|
-
field
|
136
|
+
field(
|
137
|
+
name: :id,
|
138
|
+
type: ID,
|
139
|
+
null: false,
|
140
|
+
description: "A unique identifier for this object",
|
141
|
+
)
|
137
142
|
upcased_field :upcased_id, ID, null: false, method: :id # upcase: true added by helper
|
138
143
|
|
139
144
|
def id
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# A stub for the NewRelic agent, so we can make assertions about how it is used
|
3
|
+
if defined?(NewRelic)
|
4
|
+
raise "Expected NewRelic to be undefined, so that we could define a stub for it."
|
5
|
+
end
|
6
|
+
|
7
|
+
module NewRelic
|
8
|
+
TRANSACTION_NAMES = []
|
9
|
+
# Reset state between tests
|
10
|
+
def self.clear_all
|
11
|
+
TRANSACTION_NAMES.clear
|
12
|
+
end
|
13
|
+
module Agent
|
14
|
+
def self.set_transaction_name(name)
|
15
|
+
TRANSACTION_NAMES << name
|
16
|
+
end
|
17
|
+
|
18
|
+
module MethodTracerHelpers
|
19
|
+
def self.trace_execution_scoped(trace_name)
|
20
|
+
yield
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -326,8 +326,8 @@ module StarTrek
|
|
326
326
|
|
327
327
|
class MutationType < GraphQL::Schema::Object
|
328
328
|
graphql_name "Mutation"
|
329
|
-
|
330
|
-
|
329
|
+
field :introduceShip, mutation: IntroduceShipMutation
|
330
|
+
# To hook up a Relay::Mutation
|
331
331
|
field :introduceShipFunction, field: IntroduceShipFunctionMutation.field
|
332
332
|
end
|
333
333
|
|
@@ -331,8 +331,7 @@ module StarWars
|
|
331
331
|
|
332
332
|
class MutationType < GraphQL::Schema::Object
|
333
333
|
graphql_name "Mutation"
|
334
|
-
|
335
|
-
field :introduceShip, field: IntroduceShipMutation.field
|
334
|
+
field :introduceShip, mutation: IntroduceShipMutation
|
336
335
|
field :introduceShipFunction, field: IntroduceShipFunctionMutation.field
|
337
336
|
end
|
338
337
|
|
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.8.0
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Mosolgo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: benchmark-ips
|
@@ -541,6 +541,7 @@ files:
|
|
541
541
|
- lib/graphql/schema/printer.rb
|
542
542
|
- lib/graphql/schema/relay_classic_mutation.rb
|
543
543
|
- lib/graphql/schema/rescue_middleware.rb
|
544
|
+
- lib/graphql/schema/resolver.rb
|
544
545
|
- lib/graphql/schema/scalar.rb
|
545
546
|
- lib/graphql/schema/timeout_middleware.rb
|
546
547
|
- lib/graphql/schema/traversal.rb
|
@@ -1053,6 +1054,7 @@ files:
|
|
1053
1054
|
- spec/graphql/schema/introspection_system_spec.rb
|
1054
1055
|
- spec/graphql/schema/loader_spec.rb
|
1055
1056
|
- spec/graphql/schema/member/accepts_definition_spec.rb
|
1057
|
+
- spec/graphql/schema/member/build_type_spec.rb
|
1056
1058
|
- spec/graphql/schema/member/has_fields_spec.rb
|
1057
1059
|
- spec/graphql/schema/member/type_system_helpers_spec.rb
|
1058
1060
|
- spec/graphql/schema/middleware_chain_spec.rb
|
@@ -1061,6 +1063,7 @@ files:
|
|
1061
1063
|
- spec/graphql/schema/printer_spec.rb
|
1062
1064
|
- spec/graphql/schema/relay_classic_mutation_spec.rb
|
1063
1065
|
- spec/graphql/schema/rescue_middleware_spec.rb
|
1066
|
+
- spec/graphql/schema/resolver_spec.rb
|
1064
1067
|
- spec/graphql/schema/scalar_spec.rb
|
1065
1068
|
- spec/graphql/schema/timeout_middleware_spec.rb
|
1066
1069
|
- spec/graphql/schema/traversal_spec.rb
|
@@ -1101,6 +1104,7 @@ files:
|
|
1101
1104
|
- spec/graphql/subscriptions/serialize_spec.rb
|
1102
1105
|
- spec/graphql/subscriptions_spec.rb
|
1103
1106
|
- spec/graphql/tracing/active_support_notifications_tracing_spec.rb
|
1107
|
+
- spec/graphql/tracing/new_relic_tracing_spec.rb
|
1104
1108
|
- spec/graphql/tracing/platform_tracing_spec.rb
|
1105
1109
|
- spec/graphql/tracing/scout_tracing_spec.rb
|
1106
1110
|
- spec/graphql/tracing_spec.rb
|
@@ -1116,6 +1120,7 @@ files:
|
|
1116
1120
|
- spec/support/lazy_helpers.rb
|
1117
1121
|
- spec/support/magic_cards/schema.graphql
|
1118
1122
|
- spec/support/minimum_input_object.rb
|
1123
|
+
- spec/support/new_relic.rb
|
1119
1124
|
- spec/support/parser/filename_example.graphql
|
1120
1125
|
- spec/support/parser/filename_example_error_1.graphql
|
1121
1126
|
- spec/support/parser/filename_example_error_2.graphql
|
@@ -1139,9 +1144,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1139
1144
|
version: 2.2.0
|
1140
1145
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1141
1146
|
requirements:
|
1142
|
-
- - "
|
1147
|
+
- - ">="
|
1143
1148
|
- !ruby/object:Gem::Version
|
1144
|
-
version:
|
1149
|
+
version: '0'
|
1145
1150
|
requirements: []
|
1146
1151
|
rubyforge_project:
|
1147
1152
|
rubygems_version: 2.6.13
|
@@ -1597,6 +1602,7 @@ test_files:
|
|
1597
1602
|
- spec/graphql/schema/introspection_system_spec.rb
|
1598
1603
|
- spec/graphql/schema/loader_spec.rb
|
1599
1604
|
- spec/graphql/schema/member/accepts_definition_spec.rb
|
1605
|
+
- spec/graphql/schema/member/build_type_spec.rb
|
1600
1606
|
- spec/graphql/schema/member/has_fields_spec.rb
|
1601
1607
|
- spec/graphql/schema/member/type_system_helpers_spec.rb
|
1602
1608
|
- spec/graphql/schema/middleware_chain_spec.rb
|
@@ -1605,6 +1611,7 @@ test_files:
|
|
1605
1611
|
- spec/graphql/schema/printer_spec.rb
|
1606
1612
|
- spec/graphql/schema/relay_classic_mutation_spec.rb
|
1607
1613
|
- spec/graphql/schema/rescue_middleware_spec.rb
|
1614
|
+
- spec/graphql/schema/resolver_spec.rb
|
1608
1615
|
- spec/graphql/schema/scalar_spec.rb
|
1609
1616
|
- spec/graphql/schema/timeout_middleware_spec.rb
|
1610
1617
|
- spec/graphql/schema/traversal_spec.rb
|
@@ -1645,6 +1652,7 @@ test_files:
|
|
1645
1652
|
- spec/graphql/subscriptions/serialize_spec.rb
|
1646
1653
|
- spec/graphql/subscriptions_spec.rb
|
1647
1654
|
- spec/graphql/tracing/active_support_notifications_tracing_spec.rb
|
1655
|
+
- spec/graphql/tracing/new_relic_tracing_spec.rb
|
1648
1656
|
- spec/graphql/tracing/platform_tracing_spec.rb
|
1649
1657
|
- spec/graphql/tracing/scout_tracing_spec.rb
|
1650
1658
|
- spec/graphql/tracing_spec.rb
|
@@ -1660,6 +1668,7 @@ test_files:
|
|
1660
1668
|
- spec/support/lazy_helpers.rb
|
1661
1669
|
- spec/support/magic_cards/schema.graphql
|
1662
1670
|
- spec/support/minimum_input_object.rb
|
1671
|
+
- spec/support/new_relic.rb
|
1663
1672
|
- spec/support/parser/filename_example.graphql
|
1664
1673
|
- spec/support/parser/filename_example_error_1.graphql
|
1665
1674
|
- spec/support/parser/filename_example_error_2.graphql
|