facebook/relay · error

Terser syntax is only supported on non-input objects or inte

Error message

Terser syntax is only supported on non-input objects or interfaces.

What it means

When resolving a type reference in the SchemaDocument, relay-docblock only supports expanding fields on plain object types and interfaces. If the referenced definition is an input object, scalar, union, or enum, it panics with this message; otherwise it would produce a normal TypeNotFound diagnostic.

Source

Thrown at compiler/crates/relay-docblock/src/ir.rs:831

                name.location,
            )]);
        }

        if let Some(type_) = schema.get_type(self.type_.item) {
            match type_ {
                Type::Object(object_id) => {
                    let object = schema.object(object_id);
                    return Ok(self.object_definitions(object, project_config));
                }
                Type::Interface(interface_id) => {
                    let interface = schema.interface(interface_id);
                    return Ok(self.interface_definitions(
                        interface.name,
                        interface_id,
                        project_config,
                    ));
                }
                _ => panic!("Terser syntax is only supported on non-input objects or interfaces."),
            }
        }

        let suggester = GraphQLSuggestions::new(schema);
        Err(vec![Diagnostic::error_with_data(
            ErrorMessagesWithData::TypeNotFound {
                type_name: self.type_.item,
                suggestions: suggester.object_type_suggestions(self.type_.item),
            },
            self.type_.location,
        )])
    }

    fn location(&self) -> Location {
        self.location
    }

    fn root_fragment_name(&self) -> Option<WithLocation<FragmentDefinitionName>> {

View on GitHub (pinned to 668b1b85e0)

Solutions

  1. Check the fragment's @argumentDefinitions/type annotation references an object or interface type, not an input/enum/union.
  2. Compare the referenced type in the latest schema SDL — it may have changed kind; update the fragment accordingly.
  3. Rename the reference to the correct output type that the fragment should spread from.
  4. If the intent is an invalid reference, fix the GraphQL text rather than expecting a friendly diagnostic.

Example fix

// before
fragment F on SomeInput @refetchable
// after
fragment F on SomeObject @refetchable
Defensive patterns

Strategy: type-guard

Validate before calling

// check the referenced type kind in your schema before relying on docblock expansion
const t = schema.getType(typeName);
if (!t) throw new Error(`Unknown type ${typeName}`);
if (!['GraphQLObjectType', 'GraphQLInterfaceType'].includes(t.constructor.name)) throw new Error(`${typeName} must be an object or interface`);

Type guard

function isExpandableType(t) { return t && (t.kind === 'OBJECT' || t.kind === 'INTERFACE'); }

Prevention

When it happens

Trigger: field_definitions is reached for a type definition that is not an object or interface — e.g. a @argumentDefinitions/@refetchable/fragment type pointing at an input object, enum, union, or scalar while processing the document.

Common situations: Using a mutation/input type name where an output object is expected in a fragment type annotation; schema changes turning an object into a union/enum; referencing a scalar type in a fragment's type condition.

Related errors


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