facebook/relay · error

Expected presence of page_info field to have been previously

Error message

Expected presence of page_info field to have been previously validated.

What it means

Same pattern as the edges lookup: while building the page_info selection for a @connection field the compiler expects schema.named_field(connection_field_type, self.connection_interface.page_info) to succeed, relying on prior connection validation. A missing page_info field on the connection type panics.

Source

Thrown at compiler/crates/relay-transforms/src/transform_connections.rs:249

                        value: arg.value.clone(),
                    });
                }
            }
            transformed_edges_field.directives.push(Directive {
                name: WithLocation::new(
                    connection_directive.name.location,
                    self.defer_stream_interface.stream_name,
                ),
                arguments,
                data: None,
                location: connection_directive.location,
            });
        }

        // Construct page_info selection
        let page_info_schema_field_id = schema
            .named_field(connection_field_type, self.connection_interface.page_info)
            .expect("Expected presence of page_info field to have been previously validated.");
        let page_info_schema_field = schema.field(page_info_schema_field_id);
        let page_info_field_name = page_info_schema_field.name.item;
        let page_info_type = page_info_schema_field.type_.inner();
        let mut page_info_ix = None;
        let mut is_aliased_page_info = false;
        let mut transformed_page_info_field = match page_info_selection {
            Some((ix, page_info_field)) => {
                page_info_ix = Some(ix);
                if let Some(alias) = page_info_field.alias {
                    // The page_info selection has to be generated as non-aliased field (since product
                    // code may be accessing the non-aliased response keys).
                    if alias.item != page_info_field_name {
                        is_aliased_page_info = true;
                        // If an alias is present, and it is different from the field name,
                        // we need to build a new page_info field
                        LinkedField {
                            alias: None,
                            definition: WithLocation::generated(page_info_schema_field_id),

View on GitHub (pinned to 668b1b85e0)

Solutions

  1. Add a pageInfo: PageInfo! field to the connection type in your schema.
  2. Align the ConnectionInterface config's page_info name with your schema (e.g. "pageInfo").
  3. Ensure the connection validation transform runs before transform_connections.
  4. Regenerate/refresh the local schema snapshot if it is out of date.

Example fix

// before
type UserConnection { edges: [UserEdge!]! }
// after
type UserConnection { edges: [UserEdge!]!, pageInfo: PageInfo! }
Defensive patterns

Strategy: validation

Validate before calling

if schema.named_field(conn_type, "pageInfo").is_none() {
    return Err(Diagnostic::error(format!("@connection type {:?} has no pageInfo field", conn_type)));
}

Type guard

fn has_page_info(schema: &Schema, t: Type, ci: &ConnectionInterface) -> bool {
    schema.named_field(t.inner(), ci.page_info).is_some()
}

Try / catch

let Some(pi_id) = schema.named_field(connection_field_type, self.connection_interface.page_info) else {
    return Err(Diagnostic::error("connection field missing pageInfo"));
};

Prevention

When it happens

Trigger: A @connection field whose connection type lacks the page_info field (or the field is named differently than the configured ConnectionInterface.page_info) when the validation pass did not reject it first.

Common situations: Custom pageInfo/page_info naming mismatch with ConnectionInterface config; server schemas that omit pageInfo; stale relay compiler config after a schema rename.

Related errors


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