GAP-1001: @mock Directive
Version: Draft
Authors: Mark Larah, Michael Rebello
Discussion: github.com/graphql/gaps/pull/1001
GAP-1001: @mock Directive
This document defines a directive for describing generated data behavior in GraphQL schemas used for local development, examples, and automated tests.
1Overview
The @mock directive may be applied to a field definition to identify the named fixture behavior that should be used when a service is running without a backing implementation.
Example № 1directive @mock(preset: String!) on FIELD_DEFINITION
2Motivation
Tools often invent their own names for generated values. A shared directive makes fixture intent visible in the schema and lets clients use the same examples across documentation, contract tests, and sandboxes.
3Semantics
A GraphQL service MAY ignore @mock in production. A tool that honors the directive SHOULD use the preset argument as a stable lookup key.
4Open questions
The draft does not yet specify a registry of preset names.