facebook/relay · error

Query exists

Error message

Query exists

What it means

Test assertion in shared_cache_preserves_arc_identity_across_operations confirming the queried operation exists in the compiled program. It fires when the test fixture's GraphQL document failed to compile into the expected operation, not from production relay-transforms logic.

Source

Thrown at compiler/crates/relay-transforms/src/generate_typename.rs:326

    /// cache: when the same `Arc<InlineFragment>` reaches `transform_inline_fragment`
    /// from multiple parallel operation traversals, every caller must receive the
    /// SAME output `Arc<InlineFragment>`. Downstream `PointerAddress`-keyed caches
    /// in `flatten` and `skip_redundant_nodes` rely on this identity. A per-call
    /// cache (which silently breaks identity) passes every fixture test but
    /// regresses end-to-end build wall by inflating downstream cache misses.
    #[test]
    fn shared_cache_preserves_arc_identity_across_operations() {
        let schema = Arc::new(
            schema::build_schema(
                "interface Node { id: ID }
                 type User implements Node { id: ID, name: String }
                 type Query { node: Node }",
            )
            .unwrap(),
        );
        let node_type = schema.get_type("Node".intern()).expect("Node exists");
        assert!(node_type.is_abstract_type(), "Node must be abstract");
        let query_type = schema.query_type().expect("Query exists");

        // Construct ONE Arc<InlineFragment> shared across multiple operations.
        // Empty selections + abstract type_condition force `transform_inline_fragment`
        // down the Replace path (it injects __isNode), so the cache stores a fresh
        // Arc whose identity we can compare across callers.
        let shared_inline = Arc::new(InlineFragment {
            type_condition: Some(node_type),
            directives: vec![],
            selections: vec![],
            spread_location: Location::generated(),
        });

        let make_op = |name: &str| {
            Arc::new(OperationDefinition {
                kind: OperationKind::Query,
                name: WithLocation::generated(OperationDefinitionName(name.intern())),
                type_: query_type,
                variable_definitions: vec![],

View on GitHub (pinned to 668b1b85e0)

Solutions

  1. Verify the test document's operation name matches the name used in the program lookup
  2. Check that the test schema fixture and operation text are well-formed and compile without errors
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at compiler/crates/relay-transforms/src/generate_typename.rs:326 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of facebook/relay@668b1b85e0 (2026-09-02). Data as JSON: /api/errors/c2259e03ea40239d. Report an issue: GitHub.