SchemaCache class

Caches and loads GraphQL introspection schemas.

Spec 037 layout — every named schema is persisted under .zfa/graphql/<name>/ with BOTH artifacts (FR-001):

  • <name>.schema.json — the raw introspection result envelope
  • <name>.schema.graphql — the SDL rendering plus flat compatibility copies .zfa/graphql/<name>.schema.json / .zfa/graphql/<name>.schema.graphql (US-1 scenario 1 path notation).

Each successful pull/write rotates the previous JSON to <name>.schema.prev.json so zfa graphql diff <name> can compare the two most recent versions (US-2 flow: pull → mutate → re-pull → diff).

The legacy single-file API (load/save/hasCache addressing <cacheDir>/schema.json) is preserved for existing callers.

Constructors

SchemaCache({required String cacheDir})

Properties

cacheDir String
Cache root, e.g. .zfa/graphql.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

hasCache() Future<bool>
Whether a legacy single-file cached schema exists.
hasSchema(String name) Future<bool>
Whether a current schema artifact exists for name.
listSchemas() List<String>
Lists all cached schema names (per-name dirs first, then flat files).
load({String? endpoint, Map<String, String>? headers, bool forceRefresh = false}) Future<GraphQLSchema>
Load schema from cache or fetch from endpoint (legacy single-file layout used by zfa graphql generate).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pull(String name, {Uri? endpoint, Map<String, String>? headers, IntrospectionTransport? transport}) Future<CachedSchema>
Fetches a schema via introspection and persists both artifacts.
read(String name) Future<CachedSchema>
Reads the current cached schema for name.
readPrevious(String name) Future<CachedSchema?>
Reads the previous version of name's schema, or null when only one version has ever been pulled.
save(Map<String, dynamic> introspectionJson) Future<void>
Save a raw introspection JSON to the legacy single-file cache.
toString() String
A string representation of this object.
inherited
write(String name, Map<String, dynamic> json) Future<CachedSchema>
Persists an already-fetched introspection result (envelope with data.__schema, or the bare data object) without any network access.

Operators

operator ==(Object other) bool
The equality operator.
inherited