# Nodejs GraphQL Field Resolvers

**URL:** <https://discuss.elastic.co/t/nodejs-graphql-field-resolvers/188424>\
**Category:** APM\
**Tags:** nodejs\
**Created:** [July 2, 2019, 1:49am UTC](https://discuss.elastic.co/t/nodejs-graphql-field-resolvers/188424 "2019-07-02T01:49:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dvisz-inf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dvisz-inf/32/42617_2.png) [@dvisz-inf](https://discuss.elastic.co/u/dvisz-inf)\
**Post date:** [July 2, 2019, 1:49am UTC](https://discuss.elastic.co/t/nodejs-graphql-field-resolvers/188424/1 "2019-07-02T01:49:13Z")

</div>

Does the node agent's graphql instrumentation support creating spans for each field resolver, or only for the complete operation?

Thanks!

---

<div class="post-metadata">

**Author:** ![stephenbelanger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenbelanger/32/34880_2.png) [@stephenbelanger](https://discuss.elastic.co/u/stephenbelanger)\
**Post date:** [July 2, 2019, 4:09am UTC](https://discuss.elastic.co/t/nodejs-graphql-field-resolvers/188424/2 "2019-07-02T04:09:58Z")

</div>

Currently it only creates a span around the whole operation, but we have discussed the possibility of spans around resolvers too. Is this an important feature for you?

---

<div class="post-metadata">

**Author:** ![dvisz-inf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dvisz-inf/32/42617_2.png) [@dvisz-inf](https://discuss.elastic.co/u/dvisz-inf)\
**Post date:** [July 2, 2019, 5:28pm UTC](https://discuss.elastic.co/t/nodejs-graphql-field-resolvers/188424/3 "2019-07-02T17:28:06Z")

</div>

It's perhaps more of a concern for developers than for production, but yes @stephenbelanger

---

<div class="post-metadata">

**Author:** ![dvisz-inf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dvisz-inf/32/42617_2.png) [@dvisz-inf](https://discuss.elastic.co/u/dvisz-inf)\
**Post date:** [July 2, 2019, 6:28pm UTC](https://discuss.elastic.co/t/nodejs-graphql-field-resolvers/188424/4 "2019-07-02T18:28:45Z")

</div>

I'm in the process now of writing an instrumentation that supports individual field resolvers.

I dug through an application based on `apollo-graphql-express` as well as some other graphql code and I've found a common function, `addResolveFunctionsToSchema` that seems like it would catch a lot (all?) use cases I'm interested in, but it is I believe what `require-in-the-middle`'s README describes as a "module-internal file"

> - `options.internals` Specifies whether `onrequire` should be called when module-internal files are loaded; defaults to `false` .

IIUC it's not currently possible in `apm-agent-nodejs` to specify this option, and it's not passed by default.

Would it be possible to allow this option?

Thanks!

---

<div class="post-metadata">

**Author:** ![dvisz-inf](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dvisz-inf/32/42617_2.png) [@dvisz-inf](https://discuss.elastic.co/u/dvisz-inf)\
**Post date:** [July 2, 2019, 10:04pm UTC](https://discuss.elastic.co/t/nodejs-graphql-field-resolvers/188424/5 "2019-07-02T22:04:22Z")

</div>

My first implementation is now functional and supports field resolves of all `GraphQLObjectType` types in a schema.

Unsurprisingly, some queries invoke a lot of field resolvers, particularly if a long list is part of the operation's return graph.

Is there any way to drop spans that only last an insignificant amount of time?

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 23, 2019, 6:04pm UTC](https://discuss.elastic.co/t/nodejs-graphql-field-resolvers/188424/6 "2019-07-23T18:04:28Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
