Comments (3)
Hey, thanks for sharing that replication script. I identified the regression in the implementation of Node#line
and Node#col
which are used when preparing error JSON. I improved the implementation in #4949 and released the fix in 2.3.3.
Does updating to that new version work for you?
from graphql-ruby.
Hi! sorry for the trouble. I would also expect it to return quickly. I wrote a script based on your example code, but for me, it was faster in 2.2 than 2.1:
Validating lots of undefined directives
require "bundler/inline"
gemfile do
gem "graphql", "~>2.3.0" # or 2.1, 2.2
end
max_byte_size = 1_000_000
max_directive_count = 100
class MySchema < GraphQL::Schema
class User < GraphQL::Schema::Object
field :login, String
end
class Query < GraphQL::Schema::Object
field :viewer, User
end
query(Query)
end
query_string = "query { viewer { login #{ "@a" * (max_byte_size / 2 - 50) } } }"
document = GraphQL.parse(query_string)
query = GraphQL::Query.new(
MySchema,
document: document,
)
puts "GraphQL-Ruby v#{GraphQL::VERSION} Starting"
pp query.valid?
puts "Done"
Output:
v2.3.2, 1.92 seconds:
~/code/graphql-ruby $ time ruby directive_test.rb
GraphQL-Ruby v2.3.2 Starting
false
Done
ruby directive_test.rb 1.92s user 0.11s system 97% cpu 2.080 total
v2.2.14, 2.06 seconds:
~/code/graphql-ruby $ time ruby directive_test.rb
GraphQL-Ruby v2.2.12 Starting
false
Done
ruby directive_test.rb 2.06s user 0.15s system 94% cpu 2.336 total
2.1.11, 4.61 seconds:
~/code/graphql-ruby $ time ruby directive_test.rb
GraphQL-Ruby v2.1.11 Starting
false
Done
ruby directive_test.rb 4.61s user 0.20s system 98% cpu 4.859 total
Are there other details that might help me replicate this issue?
In the meantime, you could try:
- validation timeout: https://graphql-ruby.org/queries/timeout.html#validation-and-analysis
validate_max_errors
: https://graphql-ruby.org/errors/overview.html#validation-errors
Let me know what you think!
from graphql-ruby.
I did some research and discovered that it is connected to the opentelemetry-instrumentation-graphql
. Surprisingly, it runs quickly with version 2.1 but significantly slower with version 2.2. Check out the specifics of a script and the experiments conducted.
require "bundler/inline"
gemfile do
source 'https://rubygems.org'
gem "base64", "~>0.2.0"
gem "graphql", "~>2.1.11" # or 2.1, 2.2
gem 'opentelemetry-instrumentation-graphql', '~> 0.28.0'
gem 'opentelemetry-sdk', '~> 1.0'
end
max_byte_size = 1_000_000
max_directive_count = 100
class MySchema < GraphQL::Schema
class User < GraphQL::Schema::Object
field :login, String
end
class Query < GraphQL::Schema::Object
field :viewer, User
end
query(Query)
trace_with GraphQL::Tracing::CallLegacyTracers
end
OpenTelemetry::SDK.configure do |c|
c.use_all('OpenTelemetry::Instrumentation::GraphQL' => { schemas: [MySchema] })
end
query_string = "query { viewer { login #{ "@a" * (max_byte_size / 2 - 50) } } }"
document = GraphQL.parse(query_string)
query = GraphQL::Query.new(
MySchema,
document: document,
)
puts "GraphQL-Ruby v#{GraphQL::VERSION} Starting"
t0 = Time.now
pp query.valid?
puts "Took: #{Time.now - t0}"
Output:
2.1
GraphQL-Ruby v2.1.12 Starting
false
Took: 1.371169
2.2
GraphQL-Ruby v2.2.14 Starting
false
Took: 248.905892
from graphql-ruby.
Related Issues (20)
- OperationStore index appears to fail with nil comparsion HOT 10
- `one_of` directive doesn't work in `InputObject`s with `ActionController::Parameters` HOT 4
- Query#fingerprint raises "TypeError: no implicit conversion of nil into String" HOT 2
- [PRO] Can't get custom directive from a document retrieved from the operation store HOT 3
- Integrate with ActiveRecord::QueryLogs (old marginalia) HOT 5
- DataDog APM not receiving data HOT 11
- Defer is not working on fragments HOT 12
- Incompatible tracers (PrometheusTrace & SentryTrace) HOT 1
- `GraphQL::Language::Nodes::Document` is not compatible with Marshal in version 2.3 HOT 1
- Guide: Mutation authorization HOT 2
- Support directives on resolvers and mutations
- `current_field` is reset in exceptions HOT 3
- Schema type system clean-up
- dataloaders not working in autoloaded mutation arguments
- Unable to use `type` as enum value HOT 1
- Incorrect Yarn doc: execute can return a Result, not only Hash HOT 2
- Max complexity not respected when using enterprise object cache HOT 2
- Can't use fields with the name object/context, reserved terms? HOT 3
- Fiber-local variables are not copied when using AsyncDataloader HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql-ruby.