-
Notifications
You must be signed in to change notification settings - Fork 10
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
Support new parser #80
Conversation
We run tests against the latest versions of GraphQL, this schedule ensures we are informed early of any breaking changes
As of GraphQL v2.2 the default ruby parser changed and no longer invokes the 'lex' step in the instrumentation so it will always return 0
on: | ||
push: | ||
pull_request: | ||
schedule: | ||
- cron: '0 8 * * 1' |
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.
I added a cron here to surface CI failures regularly as GraphQL Ruby changes, rather than only discovering them when making an unrelated PR
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.
Would this trigger a notification? Or just a badge refresh on README (which looks broken to me)
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.
https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/notifications-for-workflow-runs A notification but only to the creator of the workflow.
Which badge in the readme are you referring to? I don't see one for this repo.
EDIT: Ah I misunderstood you mean that the badge is currently broken, which is why I can't see it
on: | ||
push: | ||
pull_request: | ||
schedule: | ||
- cron: '0 8 * * 1' |
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.
Would this trigger a notification? Or just a badge refresh on README (which looks broken to me)
def capture_validation_time(context) | ||
# Queries may already be lexed and parsed before execution (whether a single query or multiplex). | ||
# If we don't have those values, use some sane defaults. | ||
if pre_context.lexing_duration.nil? | ||
if [nil, 0].include?(pre_context.lexing_duration) | ||
pre_context.lexing_start_time_offset = pre_context.multiplex_start_time | ||
pre_context.lexing_duration = 0.0 | ||
end |
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.
Wondering if we should just skip all this conditional for lexing/parsing and default the durations to 0.0
to start with and fallback to multiplex_start_time
if neither of the start times exist.
Then the test helper wouldn't be needed either?
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.
You can probably ignore this for now tbh, let's just focus on fixing the immediate issue
def capture_validation_time(context) | ||
# Queries may already be lexed and parsed before execution (whether a single query or multiplex). | ||
# If we don't have those values, use some sane defaults. | ||
if pre_context.lexing_duration.nil? | ||
if [nil, 0].include?(pre_context.lexing_duration) | ||
pre_context.lexing_start_time_offset = pre_context.multiplex_start_time | ||
pre_context.lexing_duration = 0.0 | ||
end |
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.
You can probably ignore this for now tbh, let's just focus on fixing the immediate issue
The new default parser for GraphQL Ruby doesn't call the
lex
step, but the tests were expecting thelexing_duration
to be non-zero. This updates the tests to to match the new behaviour of:lexing_duration
for GraphQL Ruby versions less than 2.2lexing_duration
for GraphQL Ruby versions of 2.2+ if they are using the C parser (which does calllex
)lexing_duration
being 0 for GraphQL Ruby versions of 2.2+ if they are not using the C parserI also encountered a bug with tests leaking state due to the pre_context not being reset in all cases.
Repro command:
This was caused by the the first test running:
and the second test running
Test 1 triggered the following trace steps:
pre_context
is only reset on the analyze_multiplex step, meaning that some data still existed on the following test. This also bypassed theexecute_multiplex
step somultiplex_start_time
doesn't get set to anything, butlexing_duration
does get set to 0When Test 2 ran the tracer we do:
and hit the check for lexing_duration it was already 0, not
nil
which meant we didn't overwrite thelexing_start_time_offset
causing it to stay atnil
, even though we did have a value available.