pull method

Future<CachedSchema> pull(
  1. String name, {
  2. Uri? endpoint,
  3. Map<String, String>? headers,
  4. IntrospectionTransport? transport,
})

Fetches a schema via introspection and persists both artifacts.

endpoint is required unless a transport is injected (tests and fixture-driven flows). Nothing is written until the fetch AND the schema parse both succeed — no partial artifacts on failure (US-1 scenario 3).

Implementation

Future<CachedSchema> pull(
  String name, {
  Uri? endpoint,
  Map<String, String>? headers,
  IntrospectionTransport? transport,
}) async {
  if (endpoint == null && transport == null) {
    throw SchemaCacheError(
      "Cannot pull schema '$name': provide --endpoint (or a transport).",
    );
  }
  final client = IntrospectionClient(transport: transport);
  final data = await client.fetch(
    endpoint ?? Uri.parse('fixture://$name'),
    headers: headers,
  );
  return _persist(name, data);
}