I’m trying to write a server plugin that uses an executionDidStart
event to recurse through a query and do something for each field in it before Apollo resolves the query. However, I need to look up the GraphQL type of each selected field, and I can’t see anywhere in the apiSchema
, the _typeMap
or the document
itself that provides this info. For example, let’s say this was my typedef file:
type User {
name: String!
}
type Post {
text: String!
author: User
}
type Query {
posts: [Post]
}
And let’s say this query came in:
query GetStuff {
posts {
author {
name
}
}
}
I need to be able to know that query->posts
is of type Post
, and query->posts->author
is of type User
. Is there anywhere Apollo Server exposes this, or do I have to re-parse the typedef myself?
Thanks very much, I’d be very grateful for any help you could give.