Simple question im sure but im new to apollo-server. im creating a ApolloServer object, and pass into it several plugins.
I want to be able to view/use the graphQL schemaHash ( i need to write it to NR as a custom attribute. )
I can see theres a interface in apollo-server-types , GraphQLServiceContext with a schemaHash however im lost in how i can use it or more easily get the schemaHash and use in my plugin event requestDidStart
You can get it in your serverWillStart method. But I wouldn’t recommend it; it’s deprecated for a reason. A comment somewhere says:
* This function returns a not particularly stable schema hash derived from a
* GraphQLSchema object. It works by running the `graphql-js` default
* introspection query against the schema and taking a SHA of a JSON encoding of
* the result. It is dependent on the precise introspection query returned by
* `graphql-js` and some of the details of how that library returns its data, so
* upgrading `graphql-js` can change its value. It was created for use in
* apollo-server-plugin-operation-registry but it is no longer used there. It is
* *not* the same as the hash used in schema and usage reporting, which is just
* a hash of the schema SDL document.
*
* For backwards-compatibility reasons, it is still calculated and passed to all
* plugin hooks, but it is not a good idea to use it for anything.
What are you trying to do that you’d like to use this hash?
Hey thanks for this. Ive been struggling a little to get off the ground with the documenation.
Yes i found that and didnt know that it could only be used in serverWillStart. Although it’s depreciated can you perhaps show me how to use it?
I need/want to write the hash of a graphQL query as a custom attribute to newrelic, so if the graph is updated or changed ie version , queries can be differentiated from each other.