“Extract” mutation name from an “OperationDefinitionNode” Object?

“Extract” mutation name from an “OperationDefinitionNode” Object?


1

I am using the webonyx/graphql-php and Laravel.

I have a single middleware that "catches" all graphql requests and I would like
to apply some logic to filter some requests depending if the request is a mutation and which mutation it is.

I "intersect" the graphql query (similar to this one) where the mutation storeCC is being called

...
"query":"mutation ($input: Card!) {
  storeCC(input: $input) {
    id
    firstName
    lastName
...

Then parse the query using the GraphQLLanguageParser into a GraphQLLanguageASTOperationDefinitionNode object

[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/WS48n.png


My question is then How can I know the mutation name (storeCC is this case.) using the OperationDefinitionNode? Is there another way to extract the mutation name (storeCC) that I am invoking from the query string?


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *