Skip to content

Instantly share code, notes, and snippets.

View benrowe-chuffed's full-sized avatar

Ben Rowe benrowe-chuffed

View GitHub Profile
@martinheld
martinheld / GraphQL introspection query via curl.md
Last active July 19, 2024 07:13
GraphQL introspection query via curl

GraphQL introspection query via curl

cat introspection_query.json

{ 
  "query": "query IntrospectionQuery {
      __schema {
        queryType { name }
        mutationType { name }
@sidouglas
sidouglas / jest-spy-on-all.js
Last active April 26, 2022 01:43
Jest spy on everything
export default (interrogate, mockImplementations = {}) => {
const spies = {}
interrogate.prototype && Object.getOwnPropertyNames(interrogate.prototype).forEach((name) => {
if (name !== 'constructor') {
spies[`${name}Spy`] = createSpy(interrogate.prototype, mockImplementations, name)
}
// AFAIK, you can't spy on a constructor
// top answer is here: https://stackoverflow.com/a/48486214/1090606
// For now, mock the entire module to assert that the constructor was called correctly.