facebook/relay · error

User type exists

Error message

User type exists

What it means

Test assertion in preserves_source_locations: schema.get_type("User") must succeed because the fixture SDL defines type User. Firing in this test context means the in-memory schema build dropped a type, indicating a build_in_memory_schema regression rather than production behavior.

Source

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

        base_source: SourceLocationKey,
        extension_sdl: &str,
        extension_source: SourceLocationKey,
    ) -> DiagnosticsResult<SchemaSet> {
        SchemaSet::from_schema_documents_with_extensions(
            &[parse_schema_document(base_sdl, base_source).unwrap()],
            &[parse_schema_document(extension_sdl, extension_source).unwrap()],
        )
    }

    #[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]

View on GitHub (pinned to 668b1b85e0)

Solutions

  1. Check the fixture SDL still defines the User type
  2. Debug build_in_memory_schema for dropped type definitions
  3. Ensure parse_schema_document succeeded on the fixture
Defensive patterns

Strategy: validation

When it happens

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