Skip to content

Cache `IntrospectionQuery` results"

Roy Zwambag requested to merge 409448-rz-introspection-cache into master

What does this MR do and why?

Caches IntrospectionQuery results, since this is called rather often and takes a lot of time (often 5+ seconds, which triggers an 'error' in the error budget). Since the results are always the same for every deploy, we cache it, and reset the cache on restart

How to set up and validate locally

  1. Enable cache_introspection_query FF
  2. go to http://gdk.test:3000/-/graphql-explorer
  3. run query multiple times, first time it should be slow, next times cached and very fast:
query IntrospectionQuery {
  __schema {
    queryType {
      name
    }
    mutationType {
      name
    }
    subscriptionType {
      name
    }
    types {
      ...FullType
    }
    directives {
      name
      description
      locations
      args {
        ...InputValue
      }
    }
  }
}

fragment FullType on __Type {
  kind
  name
  description
  fields(includeDeprecated: true) {
    name
    description
    args {
      ...InputValue
    }
    type {
      ...TypeRef
    }
    isDeprecated
    deprecationReason
  }
  inputFields {
    ...InputValue
  }
  interfaces {
    ...TypeRef
  }
  enumValues(includeDeprecated: true) {
    name
    description
    isDeprecated
    deprecationReason
  }
  possibleTypes {
    ...TypeRef
  }
}

fragment InputValue on __InputValue {
  name
  description
  type {
    ...TypeRef
  }
  defaultValue
}

fragment TypeRef on __Type {
  kind
  name
  ofType {
    kind
    name
    ofType {
      kind
      name
      ofType {
        kind
        name
        ofType {
          kind
          name
          ofType {
            kind
            name
            ofType {
              kind
              name
              ofType {
                kind
                name
              }
            }
          }
        }
      }
    }
  }
}

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #409448 (closed)

Edited by Roy Zwambag

Merge request reports