-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proof of concept, Allow conditional introspection #4551
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,7 @@ def selected_operation_name | |
# @param max_complexity [Numeric] the maximum field complexity for this query (falls back to schema-level value) | ||
# @param except [<#call(schema_member, context)>] If provided, objects will be hidden from the schema when `.call(schema_member, context)` returns truthy | ||
# @param only [<#call(schema_member, context)>] If provided, objects will be hidden from the schema when `.call(schema_member, context)` returns false | ||
def initialize(schema, query_string = nil, query: nil, document: nil, context: nil, variables: nil, validate: true, static_validator: nil, subscription_topic: nil, operation_name: nil, root_value: nil, max_depth: schema.max_depth, max_complexity: schema.max_complexity, except: nil, only: nil, warden: nil) | ||
def initialize(schema, query_string = nil, query: nil, document: nil, context: nil, variables: nil, validate: true, static_validator: nil, subscription_topic: nil, operation_name: nil, root_value: nil, max_depth: schema.max_depth, max_complexity: schema.max_complexity, except: nil, only: nil, warden: nil, disable_introspection_entry_points: true) | ||
# Even if `variables: nil` is passed, use an empty hash for simpler logic | ||
variables ||= {} | ||
@schema = schema | ||
|
@@ -114,6 +114,7 @@ def initialize(schema, query_string = nil, query: nil, document: nil, context: n | |
self.static_validator = static_validator if static_validator | ||
context_tracers = (context ? context.fetch(:tracers, []) : []) | ||
@tracers = schema.tracers + context_tracers | ||
@disable_introspection_entry_points = disable_introspection_entry_points | ||
|
||
# Support `ctx[:backtrace] = true` for wrapping backtraces | ||
if context && context[:backtrace] && [email protected]?(GraphQL::Backtrace::Tracer) | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this won't play nice with a Fiber- or Thread-based application server (like Puma) because in that case, multiple queries may be running at the same time, using the same schema. If one query disabled entry points on the schema, then another query enabled them again, the first query would use the setting from the second query. (It's a memory conflict: the schema is shared between queries, so it the schema is changed, all currently-running queries would use the modified schema.)
Technically, it would still work in forking servers (like Unicorn), but modifying the Schema class while the application is running would cause it to be copied into fork-specific memory which is slow and a poor use of space. (Although I wouldn't be surprised if some other element of Schema setup causes it to be written into the fork's own heap, so that may not be a new problem...)