facebook/relay · error

Expected to have access to AST and docblock sources.

Error message

Expected to have access to AST and docblock sources.

What it means

extract_schema_documents_for_resolvers panics when it cannot obtain the AST and docblock sources for a project — the expected source objects are None. This is an environment/setup invariant: the compiler was asked to build a resolvers schema without the inputs it requires.

Source

Thrown at compiler/crates/relay-compiler/src/build_project/build_resolvers_schema/extract_docblock_ir.rs:221

                    // But for fields, we may need to validate the correctness
                    // of the @rootFragment.
                    // And here we're reading GraphQL asts for the file,
                    // and keeping them together with Docblock ASTs
                    if !result.fields.is_empty() {
                        field_asts_and_definitions.insert(
                            file_path,
                            (
                                result.fields,
                                graphql_asts.get_executable_definitions_for_file(file_path),
                            ),
                        );
                    }
                }
                Err(err) => errors.extend(err),
            }
        }
    } else {
        panic!("Expected to have access to AST and docblock sources.");
    }

    if errors.is_empty() {
        Ok(ResolverSchemaDocuments {
            type_asts: TypeAsts(type_asts),
            field_asts_and_definitions: FieldAstsAndDefinitions(field_asts_and_definitions),
        })
    } else {
        Err(errors)
    }
}

View on GitHub (pinned to 668b1b85e0)

Solutions

  1. Verify the project's src root and resolver configuration in relay.config.json point at real directories
  2. Ensure all source files under the project are readable (permissions, symlinks) and present
  3. Clear compiler cache/state and rerun `relay-compiler`; report upstream if sources exist but extraction still returns None
Defensive patterns

Strategy: validation

Validate before calling

// Precheck before invoking schema extraction
if !std::path::Path::new(&project.src_root).exists() {
    return Err("resolver src root missing; check relay.config.json");
}

Type guard

fn has_sources(sources: &Option<SchemaSources>) -> bool {
    sources.is_some()
}

Try / catch

// not catchable; ensure extraction returns Err instead of panicking when sources are None

Prevention

When it happens

Trigger: Running extract_docblock_ir_for_project on a project where source extraction returned no AST/docblock sources (the else branch of the source lookup).

Common situations: Misconfigured project in relay.config (wrong src/ roots or resolver directories), unreadable/missing files, or a file watcher/partial state where sources were not collected before schema build.

Related errors


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