-
Notifications
You must be signed in to change notification settings - Fork 294
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
Hooks for graphql parse and validate functions #1167
Comments
The original use case was only for
The main challenge for every hook is always to figure out what makes the most sense to pass to the hook. Implementing the hook itself is usually not a lot of code.
That would definitely be considered and contributions are welcome! |
@rochdev I took at a look at implementing hooks for I have access to the values during the parse and validate step in my application, is there anything I can do from that side (outside of adding a new span) that would let me pass them into the parse and validate hooks? I'm available to make the contribution for the new hooks, but if you could give some direction on how to pass the variable info to them that would be great! |
@quinnlangille The main issue is that variable values only make sense in the context of the execution since they are applied to the result of the |
I mostly just want to see the variables in the same span (trace would also be fine) as the query they're used in. We have both the query and variables printing in the execute step now, but on requests that fail on parse, validate or generally before the execute step we can only see the query. Being able to pass the variables to a parse/validate hook (like we do for execute) would help with debugging since we could easily recreate the failing request. We have access to the variables during parse/validate in the app but I'm not sure if/how I can pass them into the appropriate span.
Not 100% what you mean here, is there a way to do this with dd-trace? Sorry if I'm missing something obvious lol again, pretty new to dd-trace |
I have a local fork for adding hooks for validate and parse, with tests implemented. Would it be possible to make a PR for review? @rochdev ? |
my implementation will not add validation as arguments, decided to go with the following, since in my opinion these are the most useful for these use cases: to modify and add spans. (span, document, errors) for validation |
I have created a PR about adding parse and validate hooks. Would appreciate help on getting this forward. EDIT: Fixed tests for PR. |
Thanks! I took a quick look earlier today and it's fine for the most part, just want to make sure of the arguments to the hooks. Let's continue the discussion in the PR. |
@quinnlangille Sorry for the late reply, I completely missed your comment. Is this still an issue for you? Can you share the code where the variables are available? Variables are only relevant from the perspective of the execution since the parsing and validation only work on the schema and the document, not on variables. Because of that, they are not directly available to |
Hey @rochdev, we managed to get the data we needed with just some regular logging outside of the trace. Going as granular as the trace our first instinct, but ended up being more of a nice to have. If the hooks were made available though (re: above comments from @thehideki81) then we could definitely make use of them |
The parse/validate hooks were just released in 1.1.0. Thanks @thehideki81 for implementing this! |
It would be great if we were able to add hooks to the GraphQL parse and validate functions, similar to what exists already for execute: https://github.com/graphql/graphql-js
Is there interest and/or a plan in implementing this in the future? Are there particular challenges or concerns about adding it?
I'd be interested in contributing to the repo myself if this is something likely to be considered for release.
The text was updated successfully, but these errors were encountered: