apollo-federation 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 446efb9b173791b74a0bfc8b6dff598f2540517b30fdcf3425a0b332303bf1f6
4
- data.tar.gz: e7ddcd984c0ce2d9573b98459006577478bbdb5cc5347f6198eba17b5aae5494
3
+ metadata.gz: 4cb2c9ccf550442d466468618bc9656f3fcdd11dc945583ad8fcf4ffd9ab2101
4
+ data.tar.gz: ee79a0157e41dd292ab53d39a8edae5f220aac31abf9d69bfb6711c9dd16b7d4
5
5
  SHA512:
6
- metadata.gz: f1978c886ed68a721c277c6589c8890445480a85998120f7454b40f45144afebb63f55ba8425473e1d04a82c39e1005639b368c5cd90d0cf5d0138a1180fb0a2
7
- data.tar.gz: 811f1c1eaf17c1c4a795b6bd1bce88a95cb2699d0e4d54e3dc152a04702f340e25b4af158de14f9d5e954d564a6693d048df7ff76ac93571abac8d00f894529e
6
+ metadata.gz: 5004bc11baa692fc1a900f30ada8210bdaef68ea55eb40b22c67db11257bd2890c186958e411f3fea7fc678ee3556301ab606de1a67b5a6f64e5ac165e180c3d
7
+ data.tar.gz: 1e2fa18db2eb2f92997724a7c60fafec104fad63d0e3ad84ba72202c70221d32f342e3df96164b6c5619cb02b42c231912407ce17591de72856385a77f000b79
@@ -1,3 +1,13 @@
1
+ ## 0.2.0 (Aug 1, 2019)
2
+
3
+ ### Features
4
+
5
+ * Add a description to the `_Service` type ([#10](https://github.com/Gusto/apollo-federation-ruby/pull/10))
6
+
7
+ ### Bug fixes
8
+
9
+ * Fix an issue coercing the `_Any` scalar in a Rails app ([#13](https://github.com/Gusto/apollo-federation-ruby/pull/13))
10
+
1
11
  ## 0.1.0 (Jun 21, 2019)
2
12
 
3
13
  * First release
data/README.md CHANGED
@@ -147,6 +147,10 @@ class User < BaseObject
147
147
  end
148
148
  ```
149
149
 
150
- ## Known Limitations and Issues
150
+ ## Known Issues and Limitations
151
151
  - Currently only works with class-based schemas
152
- - Does add directives to the output of `Schema.to_definition`. Since `graphql-ruby` doesn't natively support schema directives, the directives will only be visible to the [Apollo Gateway](https://www.apollographql.com/docs/apollo-server/api/apollo-gateway/) through the `Query._service` field (see the [Apollo Federation specification](https://www.apollographql.com/docs/apollo-server/federation/federation-spec/))
152
+ - Does not add directives to the output of `Schema.to_definition`. Since `graphql-ruby` doesn't natively support schema directives, the directives will only be visible to the [Apollo Gateway](https://www.apollographql.com/docs/apollo-server/api/apollo-gateway/) through the `Query._service` field (see the [Apollo Federation specification](https://www.apollographql.com/docs/apollo-server/federation/federation-spec/))
153
+
154
+ ## Maintainers
155
+ * [Rylan Collins](https://github.com/rylanc)
156
+ * [Noa Elad](https://github.com/noaelad)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'apollo-federation/version'
2
4
  require 'apollo-federation/schema'
3
5
  require 'apollo-federation/object'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'graphql'
2
4
 
3
5
  module ApolloFederation
@@ -6,9 +8,11 @@ module ApolloFederation
6
8
 
7
9
  def self.coerce_input(value, _ctx)
8
10
  # TODO: Should we convert it to a Mash-like object?
9
- result = Hash.new
10
- value.each_key do |key|
11
- result[key.to_sym] = value[key]
11
+ result = {}
12
+
13
+ # `value` can be an ActionController::Parameters instance
14
+ value.each_pair do |key, val|
15
+ result[key.to_sym] = val
12
16
  end
13
17
 
14
18
  result
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'graphql'
2
4
  require 'apollo-federation/any'
3
5
 
@@ -24,14 +26,17 @@ module ApolloFederation
24
26
  type = context.warden.get_type(typename)
25
27
  if type.nil? || type.kind != GraphQL::TypeKinds::OBJECT
26
28
  # TODO: Raise a specific error class?
27
- raise "The _entities resolver tried to load an entity for type \"#{typename}\", but no object type of that name was found in the schema"
29
+ raise "The _entities resolver tried to load an entity for type \"#{typename}\"," \
30
+ ' but no object type of that name was found in the schema'
28
31
  end
29
32
 
30
33
  # TODO: Handle non-class types?
31
34
  type_class = type.metadata[:type_class]
32
- result = type_class.respond_to?(:resolve_reference) ?
33
- type_class.resolve_reference(reference, context) :
34
- reference
35
+ if type_class.respond_to?(:resolve_reference)
36
+ result = type_class.resolve_reference(reference, context)
37
+ else
38
+ result = reference
39
+ end
35
40
 
36
41
  # TODO: This isn't 100% correct: if (for some reason) 2 different resolve_reference calls
37
42
  # return the same object, it might not have the right type
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'graphql'
2
4
 
3
5
  module ApolloFederation
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'graphql'
2
4
  require 'apollo-federation/service'
3
5
 
@@ -7,16 +9,18 @@ module ApolloFederation
7
9
  '_Any',
8
10
  '_Entity',
9
11
  '_Service',
10
- ]
12
+ ].freeze
11
13
  FEDERATION_QUERY_FIELDS = [
12
14
  '_entities',
13
15
  '_service',
14
- ]
16
+ ].freeze
15
17
 
16
18
  def build_object_type_node(object_type)
17
19
  object_node = super
18
20
  if query_type?(object_type)
19
- federation_fields = object_node.fields.select { |field| FEDERATION_QUERY_FIELDS.include?(field.name) }
21
+ federation_fields = object_node.fields.select do |field|
22
+ FEDERATION_QUERY_FIELDS.include?(field.name)
23
+ end
20
24
  federation_fields.each { |field| object_node = object_node.delete_child(field) }
21
25
  end
22
26
  merge_directives(object_node, object_type.metadata[:federation_directives])
@@ -48,7 +52,7 @@ module ApolloFederation
48
52
  (directives || []).each do |directive|
49
53
  node = node.merge_directive(
50
54
  name: directive[:name],
51
- arguments: build_arguments_node(directive[:arguments])
55
+ arguments: build_arguments_node(directive[:arguments]),
52
56
  )
53
57
  end
54
58
  node
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'apollo-federation/has_directives'
2
4
 
3
5
  module ApolloFederation
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module ApolloFederation
3
4
  module HasDirectives
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'apollo-federation/has_directives'
2
4
 
3
5
  module ApolloFederation
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'apollo-federation/entities_field'
2
4
  require 'apollo-federation/service_field'
3
5
  require 'apollo-federation/entity'
@@ -28,10 +30,10 @@ module ApolloFederation
28
30
 
29
31
  possible_entities = orig_defn.types.values.select do |type|
30
32
  !type.introspection? && !type.default_scalar? &&
31
- type.metadata[:federation_directives]&.any? {|directive| directive[:name] == 'key'}
33
+ type.metadata[:federation_directives]&.any? { |directive| directive[:name] == 'key' }
32
34
  end
33
35
 
34
- if possible_entities.length > 0
36
+ if !possible_entities.empty?
35
37
  entity_type = Class.new(Entity) do
36
38
  possible_types(*possible_entities)
37
39
  end
@@ -46,7 +48,7 @@ module ApolloFederation
46
48
  end
47
49
 
48
50
  def federation_sdl
49
- @sdl ||= begin
51
+ @federation_sdl ||= begin
50
52
  document_from_schema = FederatedDocumentFromSchemaDefinition.new(self)
51
53
  GraphQL::Language::Printer.new.print(document_from_schema.document)
52
54
  end
@@ -54,4 +56,3 @@ module ApolloFederation
54
56
  end
55
57
  end
56
58
  end
57
-
@@ -1,8 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'graphql'
2
4
 
3
5
  module ApolloFederation
4
6
  class Service < GraphQL::Schema::Object
5
7
  graphql_name '_Service'
8
+ description 'The sdl representing the federated service capabilities. Includes federation ' \
9
+ 'directives, removes federation types, and includes rest of full schema after schema ' \
10
+ 'directives have been applied'
6
11
 
7
12
  field(:sdl, String, null: true)
8
13
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'graphql'
2
4
  require 'apollo-federation/service'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ApolloFederation
2
- VERSION = "0.1.0"
4
+ VERSION = '0.2.0'
3
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apollo-federation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noa Elad
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-06-21 00:00:00.000000000 Z
12
+ date: 2019-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: graphql
@@ -25,6 +25,20 @@ dependencies:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: actionpack
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
28
42
  - !ruby/object:Gem::Dependency
29
43
  name: pry-byebug
30
44
  requirement: !ruby/object:Gem::Requirement
@@ -53,6 +67,20 @@ dependencies:
53
67
  - - ">="
54
68
  - !ruby/object:Gem::Version
55
69
  version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
56
84
  - !ruby/object:Gem::Dependency
57
85
  name: rspec
58
86
  requirement: !ruby/object:Gem::Requirement
@@ -67,6 +95,34 @@ dependencies:
67
95
  - - ">="
68
96
  - !ruby/object:Gem::Version
69
97
  version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: rubocop
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: 0.72.0
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: 0.72.0
112
+ - !ruby/object:Gem::Dependency
113
+ name: rubocop-rspec
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
70
126
  description: A Ruby implementation of Apollo Federation
71
127
  email:
72
128
  - noa.elad@gusto.com