Skip to main content

Field usage and other protocols

A pact recorded from the hosted mock can now expect only the fields the consumer reads, and the mock records GraphQL, gRPC and event channels as well as REST. See Report which fields the consumer reads and GraphQL, gRPC and event channels.

  • Only what was read. Load the mock's browser recorder (<script src="…/__capture__/recorder.js" data-capture="Orders UI@3.4.0">) or call recordFieldUsage from the SDK's npm package (<package>/fieldUsage), and the consumer reports which response fields its code reads. Loose and Only what was read on Generate a pact from a mock switch on once a report arrives; until then they are off and say why. The pact then expects only those fields, each one left out is listed with the reason, and an operation no report covers keeps every field and says so.
  • From a pipeline. apiome pact record --fields read and the GitHub Action's fields: read do the same; without a report the generation is refused with the reason.
  • GraphQL. Operations sent to …/graphql with X-Mock-Capture become GraphQL-over-HTTP interactions, one per operation.
  • gRPC. Unary calls with the x-mock-capture metadata entry become protobuf-plugin interactions, with the version's descriptors in the pact, so the provider verifies them like any plugin pact.
  • Event channels. WebSocket and SSE subscriptions opened with the tag record the messages the mock delivers, and an on-demand publish with the tag records its record. Each channel becomes an Asynchronous/Messages interaction, checked against the AsyncAPI form of the mocked version.
  • Nothing silently dropped. A streaming gRPC method, a refused GraphQL document, a report for a consumer version with no calls, or a report item no operation matches is listed with the reason.

The report format and the mock routes are on Capture for a consumer.