-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from nulogy/generate-schema-regardless-of-visi…
…bility Generate schema regardless of visibility
- Loading branch information
Showing
11 changed files
with
100 additions
and
78 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module NulogyGraphqlApi | ||
VERSION = "3.0.1" | ||
VERSION = "4.0.0" | ||
end |
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
Binary file not shown.
61 changes: 61 additions & 0 deletions
61
spec/integration/lib/nulogy_graphql_api/tasks/schema_generator_spec.rb
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,61 @@ | ||
class VisibleQuery < GraphQL::Schema::Object | ||
field :test, String, null: false | ||
end | ||
|
||
class InvisibleQuery < GraphQL::Schema::Object | ||
field :test, String, null: false | ||
|
||
def self.visible?(_context) | ||
false | ||
end | ||
end | ||
|
||
RSpec.describe NulogyGraphqlApi::Tasks::SchemaGenerator do | ||
it "stringifies the schema" do | ||
fake_schema = Class.new(GraphQL::Schema) do | ||
query VisibleQuery | ||
end | ||
task = NulogyGraphqlApi::Tasks::SchemaGenerator.new("schema_output_path", fake_schema) | ||
|
||
result = task.generate_schema | ||
|
||
expect(result).to eq(<<~GQL) | ||
schema { | ||
query: VisibleQuery | ||
} | ||
type VisibleQuery { | ||
test: String! | ||
} | ||
GQL | ||
end | ||
|
||
it "stringifies invisible parts of the schema" do | ||
fake_schema = Class.new(GraphQL::Schema) do | ||
query InvisibleQuery | ||
end | ||
task = NulogyGraphqlApi::Tasks::SchemaGenerator.new("schema_output_path", fake_schema) | ||
|
||
result = task.generate_schema | ||
|
||
expect(result).to eq(<<~GQL) | ||
schema { | ||
query: InvisibleQuery | ||
} | ||
type InvisibleQuery { | ||
test: String! | ||
} | ||
GQL | ||
end | ||
|
||
it "does not alter the given schema" do | ||
fake_schema = Class.new(GraphQL::Schema) | ||
old_warden = fake_schema.warden_class | ||
task = NulogyGraphqlApi::Tasks::SchemaGenerator.new("schema_output_path", fake_schema) | ||
|
||
task.generate_schema | ||
|
||
expect(fake_schema.warden_class).to eq(old_warden) | ||
end | ||
end |