Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

[FEAT] Cache introspection queries #62

Open
alecgorge opened this issue Sep 12, 2019 · 1 comment
Open

[FEAT] Cache introspection queries #62

alecgorge opened this issue Sep 12, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@alecgorge
Copy link

Is your feature request related to a problem? Please describe.
This project looks almost perfect for addressing some hotspots in our code!

Describe the solution you'd like
I would like to be able to apply caching to the introspection fields/queries. Introspection queries are currently the heaviest GraphQL query we face because we have a very large schema—but our schema doesn't change while the server is running. I plan on using a cache key of the build number + schema name in production.

It isn't clear to me how to attach caching to these automatically provided fields.

Additional context
We are open to other solutions besides caching at the field level but aren't keen on directly matching against the query because when we open up our GraphQL API to more 3rd parties we can't ensure they always introspect in the same way.

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
              }
            }
          }
        }
      }
    }
  }
}
@alecgorge alecgorge added the enhancement New feature or request label Sep 12, 2019
@thebadmonkeydev
Copy link
Collaborator

@alecgorge I'm sorry it has taken so long to respond to this issue. I no longer work at Stackshare and don't have write access to the repo anymore.

That's an interesting use case that I haven't seen before (caching introspection queries). I'm not entirely sure whether graphql-cache is the write tool for this issue or not. We make a lot of assumptions about what it is that we're caching. I'll do some investigation and see if I can come up with a way to accomplish this in a stable way.

@thebadmonkeydev thebadmonkeydev self-assigned this Oct 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants