I am going to move this into the GraphQL API FAQ’s category as it is more suited to your question.
At this stage, there is no ability to calculate the complexity of a mutation with the V2 API.
I notice in your error, it says your query has a complexity of 30001. You have a complexity limit of 10,000,000 per minute per account. In the error it states that the max complexity if 9966, this is because you have already used a large portion of the rate limit within the last 60 seconds.
This means that this query could easily be accounted for in the rate limit.
I would suggest that you implement a retry process in your code if you receive this error. You should retry this mutation after a minute, and it should return a successful response.
If the error says the complexity of your mutation is over 10,000,000, you would need to restructure your code to account for you. You may need to use multiple API requests to