powerfoki.blogg.se

React private cache
React private cache








react private cache

At the same time, we don't think developers should have to specify cache hints for every single field in their schema. Our philosophy behind Apollo Server caching is that a response should only be considered cacheable if every part of that response opts in to being cacheable.

  • Fields that return a non-scalar type (object, interface, or union) or a list of non-scalar types.Īll other schema fields (i.e., non-root fields that return scalar types) instead inherit their default maxAge from their parent field.
  • Because every GraphQL operation includes a root field, this means that by default, no operation results are cached unless you set cache hints!.
  • Root fields (i.e., the fields of the Query, Mutation, and Subscription types).
  • The response's scope is PRIVATE if any field's scope is PRIVATE.īy default, the following schema fields have a maxAge of 0 if you don't specify one:.
  • If that value is 0, the entire result is not cached.
  • The response's maxAge equals the lowest maxAge among all fields.
  • Calculating cache behaviorįor security, each operation response's cache behavior is calculated based on the most restrictive cache hints among the result's fields: This can be useful when resolving a union or interface field, which might return one of multiple object types.

    react private cache

    This method enables you to get the default cache hint for a particular object type. To use the directive, you must add the following definitions to your server's schema: In your schema (static)Īpollo Server recognizes the directive, which you can use in your schema to define caching behavior either for a single field, or for all fields that return a particular type. These details can vary significantly, even among the fields of a single object type. Whether a cached value is global or user-specific.

    react private cache

    How long a cached value should remain valid.Which fields of your schema can be cached safely.Note that when setting cache hints, it's important to understand: You can define field-level cache hints statically in your schema definition or dynamically in your resolvers (or both). You can then use this calculation to support any form of cache implementation you want, such as by providing it to your CDN via a Cache-Control header. When Apollo Server resolves an operation, it calculates the result's correct cache behavior based on the most restrictive settings among the result's fields.










    React private cache