Skip to content

Snapshot example services' GraphQL schemas as insta tests (backport of #6542)#6545

Closed
ma2bd wants to merge 3 commits into
testnet_conwayfrom
ma2bd/graphql-schema-snapshot-conway
Closed

Snapshot example services' GraphQL schemas as insta tests (backport of #6542)#6545
ma2bd wants to merge 3 commits into
testnet_conwayfrom
ma2bd/graphql-schema-snapshot-conway

Conversation

@ma2bd

@ma2bd ma2bd commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Motivation

Backport of #6542 to testnet_conway.

We record each application's serde/BCS formats as an insta snapshot (via BcsApplication) so that unintended changes to operation/message/event encodings show up as a reviewable diff. This adds the equivalent guard for the GraphQL schema exposed by each application's service.

Proposal

For every example that implements BcsApplication and exposes a GraphQL service, add a #[cfg(test)] schema_sdl test in service.rs that snapshots the service's GraphQL SDL. Most services extract a private fn schema(&self) -> Schema<…> and have handle_query delegate to it, so the snapshotted SDL cannot drift from what is served; the test builds the service against a MockServiceRuntime and snapshots schema().sdl().

The snapshot tests are gated #[cfg(not(target_arch = "wasm32"))] (mirroring the existing tests/format.rs convention), because insta is a non-wasm dev-dependency and the example services are also compiled for wasm32 with --all-targets.

Notes specific to this backport

This is not a clean cherry-pick of #6542testnet_conway differs from main in several examples, so the following were adapted and the affected SDL snapshots regenerated against testnet_conway:

  • counter keeps its tutorial // ANCHOR markers and QueryRoot/MutationRoot structs, so its handle_query is left intact and the test builds the schema directly (in a separate gated schema_tests module).
  • native-fungible uses NativeFungibleOperation here (vs FungibleOperation on main).
  • matching-engine loads its state via root_view_storage_context() here (its Parameters has no price_decimals field), so the test uses the simple load path.
  • fungible imports OwnerSpender from a different module here.
  • wrapped-fungible gained an insta non-wasm dev-dependency (it was already present on the other examples).
  • task-processor gained a wasmer-featured linera-sdk dev-dependency (needed by the mock ServiceRuntime).
  • llm can't construct its service in a unit test (new() downloads model weights), so its test builds the schema directly; this does not affect the SDL.

Test Plan

  • cargo test -p <example> --bin <example>_service schema_sdl passes for all 16 services; re-running without INSTA_UPDATE confirms the SDL is deterministic.
  • cargo fmt -- --check (pinned nightly) is clean across the examples workspace.
  • cargo clippy --all-targets --all-features --target wasm32-unknown-unknown compiles (the schema tests are excluded from wasm).
  • Note: on aarch64 hosts, gen-nft and llm need RUSTFLAGS=-C target-feature=+fullfp16 to build candle; irrelevant on x86 CI.

Release Plan

  • These changes follow the usual release cycle.

Links

@ma2bd ma2bd closed this Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant