Skip to content

Instantly share code, notes, and snippets.

@timsuchanek
Created January 7, 2020 14:35
Show Gist options
  • Save timsuchanek/11491f7da6d88e44229072b2ac1fa2d4 to your computer and use it in GitHub Desktop.
Save timsuchanek/11491f7da6d88e44229072b2ac1fa2d4 to your computer and use it in GitHub Desktop.
Are we called within a graphql-js resolver?
import callsite from 'callsite'
export function isGraphQLStack() {
const stack = callsite()
const functions = stack.map(s => s.getFunctionName())
return (
functions.includes('resolveFieldsValueOrError') &&
functions.includes('resolveField') &&
functions.includes('executeFields')
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment