facebook/relay · error

User.id exists

Error message

User.id exists

What it means

Test assertion in preserves_source_locations: the User object must expose an id field. Firing means field lookup on the built object failed, pointing at a regression in field storage or naming during the in-memory schema build.

Source

Thrown at compiler/crates/schema-set/src/build_in_memory_schema.rs:758

    }

    #[test]
    fn preserves_source_locations() {
        let sdl = "type Query { me: User }\n\ntype User { id: ID name: String }";
        let source = SourceLocationKey::standalone("user.graphql");
        let schema = build_in_memory_schema(&schema_set_from(sdl, source)).unwrap();

        // The `User` type's name points back at the original source file, not a
        // generated location — this is the whole purpose of the direct build.
        let user_type = schema.get_type("User".intern()).expect("User type exists");
        let user = schema.object(user_type.get_object_id().expect("User is an object"));
        assert_eq!(user.name.location.source_location(), source);
        assert_ne!(user.name.location, Location::generated());

        // Field locations are preserved too.
        let id_field_id = schema
            .named_field(user_type, "id".intern())
            .expect("User.id exists");
        let id_field = schema.field(id_field_id);
        assert_eq!(id_field.name.location.source_location(), source);
        assert_ne!(id_field.name.location, Location::generated());

        // Sanity: the schema is structurally usable (root + resolved field type).
        assert!(schema.query_type().is_some());
        assert!(matches!(id_field.type_, schema::TypeReference::Named(_)));
    }

    #[test]
    fn resolves_builtin_scalars_and_defaults() {
        let sdl = "type Query { name: String }";
        let source = SourceLocationKey::standalone("q.graphql");
        let schema = build_in_memory_schema(&schema_set_from(sdl, source)).unwrap();

        // `String` is implicit in the SDL but must exist in the built schema.
        assert!(schema.get_type("String".intern()).is_some());
        // `load_defaults` ran: __typename is queryable.

View on GitHub (pinned to 668b1b85e0)

Solutions

  1. Check the fixture SDL still declares id on User
  2. Inspect field registration in build_in_memory_schema
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at compiler/crates/schema-set/src/build_in_memory_schema.rs:758 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/612568ed85c62488. Report an issue: GitHub.