Look through definitions to find an operation type #42
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.
Why
It's weird that often the link logs with undefined type
What:
For documents with queries and fragment definitions, often I was noticing that the operation type was reported as undefined.
The root cause is that we were looking at the first definition in the query, which in our app is often a Fragment Definition instead of an Operation Definition and so doesn't have an operationType (query/mutation etc).
So instead since most documents have a single operation, I'm trying to find and report its operationType instead of looking only at the first definition.
How:
This change simply looks through to find one that isn't undefined. It's still picking one from an array, but I think this is generally going to give better results than the previous heuristic of taking the first.
Checklist: