dgraph-io/dgraph · error

Unable to find the type %s on the remote schema

Error message

Unable to find the type %s on the remote schema

What it means

expandTypeRecursively walks the remote GraphQL schema to flatten nested types reachable from a starting type. If a type name referenced during expansion is not present in the remote schema's type map, this error is thrown, meaning the schema and the referenced types are inconsistent (e.g. an interface, union, or nested field references a type that was never defined or was dropped).

Source

Thrown at graphql/schema/remote.go:570

				len(typ.Fields)+len(typ.InputFields))
			param.typesToFields[typ.Name] = append(param.typesToFields[typ.Name],
				typ.Fields...)
			param.typesToFields[typ.Name] = append(param.typesToFields[typ.Name],
				typ.InputFields...)
			// Expand the non scalar types.
			for _, field := range param.typesToFields[typ.Name] {
				if !isGraphqlSpecScalar(field.Type.Name) {
					// expand this field.
					err := expandTypeRecursively(field.Type.NamedType(), param)
					if err != nil {
						return err
					}
				}
			}
		}
	}
	if !typeFound {
		return errors.Errorf("Unable to find the type %s on the remote schema", typenameToExpand)
	}
	return nil

}

// expandType will expand the nested type into flat structure. For eg. Country having a filed called
// states of type State is expanded as Country and State. Scalar fields won't be expanded.
// It also expands deep nested types.
func expandType(typeToBeExpanded *gqlType,
	remoteTypes map[string]*types) (map[string][]*gqlField, error) {
	if isGraphqlSpecScalar(typeToBeExpanded.NamedType()) {
		return nil, nil
	}

	param := &expandTypeParams{
		expandedTypes: make(map[string]struct{}),
		typesToFields: make(map[string][]*gqlField),
		remoteTypes:   remoteTypes,

View on GitHub (pinned to 759e242be6)

Solutions

  1. Fix the GraphQL query/schema so every referenced type (including fragment targets and nested field types) is defined in the remote schema.
  2. Re-run introspection against the remote to get a complete schema (ensure the remote exposes all types, not just query roots).
  3. Check for stale/cached remote schema copies and refresh them.
  4. If the type is intentionally absent, remove the fields/fragments referencing it before calling expandType.

Example fix

// before (fragment references type missing on remote)
fragment F on MissingType { id }
// after (use a type that exists in the remote schema)
fragment F on ExistingType { id }
Defensive patterns

Strategy: validation

Validate before calling

// verify all types referenced in the query exist in the remote schema before expansion
for _, t := range referencedTypeNames(query) {
    if remoteSchema.Types().ForName(t) == nil {
        return fmt.Errorf("type %s missing from remote schema", t)
    }
}

Type guard

func typeExists(schema Schema, name string) bool {
    return schema.Types().ForName(name) != nil
}

Try / catch

types, err := expandType(remoteSchema, entrypoint)
if err != nil {
    if strings.Contains(err.Error(), "Unable to find the type") {
        // refresh introspection / fix fragment target
        return refreshAndRetry()
    }
    return err
}

Prevention

When it happens

Trigger: Calling expandType/expandTypeRecursively (via schema joining/introspection during schema generation) when a field's type or a nested/inline fragment type name (typenameToExpand) does not exist in the remote schema's types.

Common situations: Remote schema introspection returned an incomplete type map; a custom resolver or federation layer dropped a type; a typo in a fragment ...on TypeName for a type not in the schema; schema changed on the remote between validation and expansion.

Related errors


AI-assisted analysis of dgraph-io/dgraph@759e242be6 (2026-09-01). Data as JSON: /api/errors/c96ea3084b568854. Report an issue: GitHub.