-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add support for the @Shareable directive * Fix rubocop offense * Add support for the @inaccessible directive * Add support for the @OverRide directive * Refactor to appease rubocop * Replace `Hash#except` with `Hash#delete_if` Oops! I didn't realise `Hash#except` was only available from Ruby 3.0 * Update README to include v2.0 directives * Fix incorrect handling of keyword args in field * Import federation directives into subgraph to opt into federation 2 (hack!) See: https://www.apollographql.com/docs/federation/federation-2/moving-to-federation-2/#opt-in-to-federation-2 This is a horrible hack. Need to figure out if there is a clean way of including this in the document and the printer output. * Enable federation 2 via a `federation_2` class method on Schema * Change `federation_2` to `federation version: 2` This is more explicit and extendable in the future if we ever need any other federation options at the schema level * Add a unit test for Schema.federation_version * Update README with how to opt in to Federation v2 * Update federation version to support semantic versioning * Add `federation__` namespace prefix to all directives when using federation version >= 2.0 * Refactor the `merge_directives` method This approach feel a little easier to understand * Fix grammar issues in test names
- Loading branch information
Showing
9 changed files
with
1,035 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
require 'graphql' | ||
require 'apollo-federation/schema' | ||
|
||
RSpec.describe ApolloFederation::Schema do | ||
describe '.federation_version' do | ||
it 'returns 1.0 by default' do | ||
schema = Class.new(GraphQL::Schema) do | ||
include ApolloFederation::Schema | ||
end | ||
|
||
expect(schema.federation_version).to eq('1.0') | ||
end | ||
|
||
it 'returns the specified version when set' do | ||
schema = Class.new(GraphQL::Schema) do | ||
include ApolloFederation::Schema | ||
federation version: '2.0' | ||
end | ||
|
||
expect(schema.federation_version).to eq('2.0') | ||
end | ||
end | ||
|
||
describe '.federation_2?' do | ||
it 'returns false when version is an integer less than 2.0' do | ||
schema = Class.new(GraphQL::Schema) do | ||
include ApolloFederation::Schema | ||
federation version: 1 | ||
end | ||
|
||
expect(schema.federation_2?).to be(false) | ||
end | ||
|
||
it 'returns false when version is less than 2.0' do | ||
schema = Class.new(GraphQL::Schema) do | ||
include ApolloFederation::Schema | ||
federation version: '1.5' | ||
end | ||
|
||
expect(schema.federation_2?).to be(false) | ||
end | ||
|
||
it 'returns true when the version is an integer equal to 2' do | ||
schema = Class.new(GraphQL::Schema) do | ||
include ApolloFederation::Schema | ||
federation version: 2 | ||
end | ||
|
||
expect(schema.federation_2?).to be(true) | ||
end | ||
|
||
it 'returns true when the version is a float equal to 2.0' do | ||
schema = Class.new(GraphQL::Schema) do | ||
include ApolloFederation::Schema | ||
federation version: 2.0 | ||
end | ||
|
||
expect(schema.federation_2?).to be(true) | ||
end | ||
|
||
it 'returns true when the version is a string greater than 2.0' do | ||
schema = Class.new(GraphQL::Schema) do | ||
include ApolloFederation::Schema | ||
federation version: '2.0.1' | ||
end | ||
|
||
expect(schema.federation_2?).to be(true) | ||
end | ||
end | ||
end |
File renamed without changes.
Oops, something went wrong.