Skip to content
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

Interpreter #1394

Merged
merged 119 commits into from
Oct 5, 2018
Merged
Changes from 1 commit
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
7b0c6d8
Pass the default value to the InputValueDefinition constructor
tenderlove Mar 9, 2018
113e9dd
Change `attr_accessor` to `attr_reader`
tenderlove Mar 9, 2018
00fa20a
Merge branch 'master' into immutable-nodes
Mar 14, 2018
032df27
Add first-class method API to Visitor
rmosolgo Apr 2, 2018
396cec3
Use class-based visitor for validation
rmosolgo Apr 2, 2018
77e22e0
Use class-based visitor for static_validation
rmosolgo Apr 2, 2018
ed9e968
Add default visitor for ALL_RULES
rmosolgo Apr 2, 2018
2f59322
Migrate rewrite to use class-based visitor
rmosolgo Apr 2, 2018
8bf1e32
Code cleanup
rmosolgo Apr 2, 2018
296627c
Merge branch '1.9-dev' into immutable-nodes
Jul 9, 2018
255842c
Merge pull request #1338 from tenderlove/immutable-nodes
Jul 9, 2018
f9fbe53
Merge branch '1.9-dev' into class-based-visitor
Jul 10, 2018
ab60ccd
migrate ArgumentNamesAreUnique to class-based
rmosolgo Jul 10, 2018
230759d
Add a test for visit methods; fill in more visit_methods
rmosolgo Jul 10, 2018
b5f9df0
Update visitor methods for new nodes
rmosolgo Jul 10, 2018
68c5614
update no_definitions_are_present for extension methods
rmosolgo Jul 10, 2018
d9fbe10
Put TypeStack back for graphql-client
rmosolgo Jul 10, 2018
b9e210f
Fix lint errors
rmosolgo Jul 10, 2018
161dafa
Fix missing require; update typestack spec
rmosolgo Jul 10, 2018
82cbc7f
Merge pull request #1290 from rmosolgo/class-based-visitor
Jul 10, 2018
030416b
Start on basic AST manipulation
rmosolgo Aug 6, 2018
7fd8ccb
Add explicit tests for perisisted nodes
rmosolgo Aug 6, 2018
fce6b84
Support deleting nodes from AST
rmosolgo Aug 6, 2018
5b7d78b
Add check for maybe-necessary method
rmosolgo Aug 7, 2018
f190344
Add prototype add child methods
rmosolgo Aug 13, 2018
0504f91
Generate methods for AST node classes
rmosolgo Aug 13, 2018
a27a807
Use generated initialize_node
rmosolgo Aug 13, 2018
bc940ba
Also freeze children arrays
rmosolgo Aug 13, 2018
62cdab5
Give up on being restrictive with visitor
rmosolgo Aug 13, 2018
ae2690b
Add visitor guide
rmosolgo Aug 13, 2018
3df83dc
Merge pull request #1740 from rmosolgo/ast-maniputation
Aug 14, 2018
0fe0938
Use an AST visitor
rmosolgo Aug 16, 2018
c3ad8b5
Try running it on Jazz schema
rmosolgo Aug 17, 2018
d79e1bd
Try to hook up input objects
rmosolgo Aug 20, 2018
a4d983b
Fix modifying fragment spreads with visitor
rmosolgo Aug 20, 2018
63df47b
Merge branch 'field-filter-instances' into field-extensions-1.9
rmosolgo Aug 20, 2018
2a20b68
Merge branch 'fix-connections' into field-extensions-1.9
rmosolgo Aug 20, 2018
c9ff734
Merge pull request #1795 from rmosolgo/field-extensions-1.9
Aug 21, 2018
0505b3b
Fix lint error
rmosolgo Aug 21, 2018
e6b4695
Merge pull request #1793 from rmosolgo/fix-replace-inline-fragment
Aug 21, 2018
23427e7
Make all Jazz schema tests pass
rmosolgo Aug 24, 2018
f85df9f
update to run introspection query
rmosolgo Aug 24, 2018
8ede1f8
Fix empty lists
rmosolgo Aug 24, 2018
6c9cc62
Support lazies in Interpreter
rmosolgo Aug 27, 2018
3325caa
try to make the interpreter run authorization
rmosolgo Aug 28, 2018
8a80091
Merge branch '1.9-dev' into interpreter
rmosolgo Aug 28, 2018
fd62944
Split out interpreter files; better authorization support
rmosolgo Aug 28, 2018
552d48b
Fix some stuff after merging
rmosolgo Aug 29, 2018
7e36ac5
Use a hacky flag to support both interpreter and non-interpreter
rmosolgo Sep 5, 2018
8ab3f6a
Support mutations the old way
rmosolgo Sep 5, 2018
e81c28a
Implement null propagation
rmosolgo Sep 6, 2018
25103fb
Merge branch '1.9-dev' into interpreter
rmosolgo Sep 14, 2018
f30b34d
Support skip & include
rmosolgo Sep 14, 2018
b383774
Fix some stuff for dairy schema with interpreter
rmosolgo Sep 17, 2018
2844c72
Try avoiding double-resolution
rmosolgo Sep 20, 2018
33ae307
Intepret with a custom AST routine
rmosolgo Sep 20, 2018
fc549e3
Fix null propagation with later writes
rmosolgo Sep 21, 2018
827608a
Improve support for nil propagation and errors
rmosolgo Sep 21, 2018
1ea1f8c
resolve late-bound types
rmosolgo Sep 21, 2018
96fb4b8
Support Tracing
rmosolgo Sep 21, 2018
8b86f53
Start multiplexing support
rmosolgo Sep 21, 2018
358388b
Skip some rescue from tests
rmosolgo Sep 21, 2018
cd2e78c
Extract Interpreter installation into a plugin
rmosolgo Sep 21, 2018
c1ef9d2
Add a guide
rmosolgo Sep 21, 2018
f66654c
more doc
rmosolgo Sep 21, 2018
c8479d3
Move context flag out of user hash
rmosolgo Sep 21, 2018
c5414aa
Remove some needless changes
rmosolgo Sep 21, 2018
9152913
remove more needless changes
rmosolgo Sep 21, 2018
eeaff01
Less nesting in interpreter
rmosolgo Sep 21, 2018
1b306fa
Update-bench
rmosolgo Sep 21, 2018
128027d
Update a few tests
rmosolgo Sep 25, 2018
55a35d6
Fix typestack spec
rmosolgo Sep 25, 2018
f36e75b
Make the tests pass without the interpreter; add a single build with …
rmosolgo Sep 25, 2018
06cce11
Fix rubocop, fix for old rubies
rmosolgo Sep 25, 2018
04de1fc
Fix travis config; fix for old rubies
rmosolgo Sep 25, 2018
4134ea8
Add interpreter to more test schemas
rmosolgo Sep 25, 2018
fc799d8
update warden_spec for interpreter'
rmosolgo Sep 25, 2018
f511ebe
Migrate system test to class-based, add interpreter run on CI
rmosolgo Sep 25, 2018
cb3fc0c
Remove needless fields stack
rmosolgo Sep 28, 2018
aa5c5c0
Remove objects stack
rmosolgo Sep 28, 2018
f21e29d
Remove path stack
rmosolgo Sep 28, 2018
c466d02
remove types stack
rmosolgo Sep 28, 2018
4340573
update tracing
rmosolgo Sep 28, 2018
3286c91
Keep a reference to trace instead of passing it everywhere
rmosolgo Sep 28, 2018
79e49d7
Trace cleanup
rmosolgo Sep 28, 2018
1f6050b
Update some test schemas to class-based
rmosolgo Sep 28, 2018
51a0b95
Start on subscriptions implementation
rmosolgo Sep 28, 2018
b020e6f
Support subscription & mutation root fields; improve support for unau…
rmosolgo Sep 29, 2018
c5127ca
Make sure interpreter-introspected types have class definitions
rmosolgo Sep 29, 2018
232b7c8
Implement batching across multiplexes
rmosolgo Sep 29, 2018
09d4a56
Fix execute_query_lazy and running one query
rmosolgo Sep 29, 2018
3fcf1c9
implement prepare for arguments
rmosolgo Sep 29, 2018
ddb9baf
Fix system tests
rmosolgo Sep 29, 2018
53a38d4
Fix rails/relay tests
rmosolgo Sep 29, 2018
1401f05
Update .node and .nodes fields
rmosolgo Oct 1, 2018
af2167e
Ignore tests that don't apply to interpreter
rmosolgo Oct 1, 2018
4f13db8
Fix client_mutation_id for interpreter
rmosolgo Oct 1, 2018
e972235
Get tracing parity
rmosolgo Oct 1, 2018
608e369
Add workaroudn for list auth test
rmosolgo Oct 2, 2018
85d6b79
Make #write_into_result private; refactor @completely_nulled
rmosolgo Oct 5, 2018
8739e56
Fix lint error
rmosolgo Oct 5, 2018
8e623f0
Remove needless late-bound type check
rmosolgo Oct 5, 2018
74295cc
Refactor to not use throw/catch
rmosolgo Oct 5, 2018
233c77b
Document a method
rmosolgo Oct 5, 2018
cf2db9a
Clean up next_selections prep
rmosolgo Oct 5, 2018
4e33f2b
Extract subscription root field logic into a module
rmosolgo Oct 5, 2018
30b3e60
Reduce usage of trace in visitor
rmosolgo Oct 5, 2018
c3481bf
fix-lint-error
rmosolgo Oct 5, 2018
505bdcc
Extract response collection from runtime
rmosolgo Oct 5, 2018
47c3c6d
Improve dead path handling
rmosolgo Oct 5, 2018
3e52d58
Remove needless legacy adapter
rmosolgo Oct 5, 2018
26b10bc
Document the multiplex interactions a little bit
rmosolgo Oct 5, 2018
f2d8f6b
merge trace and visitor into runtime, since they have the same lifecy…
rmosolgo Oct 5, 2018
8b31eed
Clarify behavior differences
rmosolgo Oct 5, 2018
057fd4a
Update some done todos
rmosolgo Oct 5, 2018
eac1add
Explain difference in tracing spec
rmosolgo Oct 5, 2018
89b8d9f
Uncomment non-broken thing
rmosolgo Oct 5, 2018
224c4a9
Rename resolve_field_2 -> resolve
rmosolgo Oct 5, 2018
b6767d6
fix lint error
rmosolgo Oct 5, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move context flag out of user hash
  • Loading branch information
rmosolgo committed Sep 21, 2018

Verified

This commit was signed with the committer’s verified signature.
codebytere Shelley Vohr
commit c8479d33b4d3a0fde8442c656b797a9c1e8b6ad3
9 changes: 4 additions & 5 deletions lib/graphql/execution/interpreter.rb
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@ module GraphQL
module Execution
class Interpreter
def run_query(query)
query.context[:__temp_running_interpreter] = true
@query = query
@schema = query.schema
evaluate
@@ -45,10 +44,10 @@ def evaluate
# TODO This is to satisfy Execution::Flatten, which should be removed
@query.context.value = trace.final_value
end
rescue
puts $!.message
puts trace.inspect
raise
# rescue
# puts $!.message
# puts trace.inspect
# raise
end
end
end
2 changes: 1 addition & 1 deletion lib/graphql/introspection/dynamic_fields.rb
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ class DynamicFields < Introspection::BaseObject

# `irep_node:` will be nil for the interpreter, since there is no such thing
def __typename(irep_node: nil)
if context[:__temp_running_interpreter]
if context.interpreter?
object.class.graphql_name
else
irep_node.owner_type.name
2 changes: 1 addition & 1 deletion lib/graphql/introspection/entry_points.rb
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ def __type(name:)
# This will probably break with non-Interpreter runtime
type = context.warden.get_type(name)
# The interpreter provides this wrapping, other execution doesnt, so support both.
if type && !context[:__temp_running_interpreter]
if type && !context.interpreter?
# Apply wrapping manually since this field isn't wrapped by instrumentation
type_type = context.schema.introspection_system.type_type
type = type_type.metadata[:type_class].authorized_new(type, context)
2 changes: 1 addition & 1 deletion lib/graphql/introspection/schema_type.rb
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ class SchemaType < Introspection::BaseObject

def types
types = @context.warden.types
if context[:__temp_running_interpreter]
if context.interpreter?
types.map { |t| t.metadata[:type_class] }
else
types
9 changes: 8 additions & 1 deletion lib/graphql/query/context.rb
Original file line number Diff line number Diff line change
@@ -149,6 +149,13 @@ def initialize(query:, values: , object:)
@path = []
@value = nil
@context = self # for SharedMethods
# It's applied as all-or-nothing, so checking this one is ok:
@interpreter = @schema.query_execution_strategy == GraphQL::Execution::Interpreter
end

# @return [Boolean] True if using the new {GraphQL::Execution::Interpreter}
def interpreter?
@interpreter
end

# @api private
@@ -222,7 +229,7 @@ def path
def_delegators :@context,
:[], :[]=, :key?, :fetch, :to_h, :namespace,
:spawn, :warden, :errors,
:execution_strategy, :strategy
:execution_strategy, :strategy, :interpreter?

# @return [GraphQL::Language::Nodes::Field] The AST node for the currently-executing field
def ast_node
3 changes: 2 additions & 1 deletion lib/graphql/schema/relay_classic_mutation.rb
Original file line number Diff line number Diff line change
@@ -29,7 +29,8 @@ class RelayClassicMutation < GraphQL::Schema::Mutation
# Override {GraphQL::Schema::Resolver#resolve_with_support} to
# delete `client_mutation_id` from the kwargs.
def resolve_with_support(**inputs)
if context[:__temp_running_interpreter]
# TODO why is this needed?
if context.interpreter?
input = inputs[:input]
else
input = inputs
2 changes: 1 addition & 1 deletion lib/graphql/types/relay/base_connection.rb
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@ def nodes
end

def edges
if context[:__temp_running_interpreter]
if context.interpreter?
@object.edge_nodes.map { |n| self.class.edge_class.new(n, @object) }
else
# This is done by edges_instrumentation
2 changes: 1 addition & 1 deletion spec/graphql/execution/interpreter_spec.rb
Original file line number Diff line number Diff line change
@@ -197,7 +197,7 @@ class Schema < GraphQL::Schema
it "is set" do
# This can be removed later, just a sanity check during migration
res = InterpreterTest::Schema.execute("{ __typename }")
assert_equal true, res.context[:__temp_running_interpreter]
assert_equal true, res.context.interpreter?
end
end