hasura/graphql-engine · error

error fetching config from server: %w

Error message

error fetching config from server: %w

What it means

This error is thrown while resolving a boolean expression (filter predicate) whose target field is expected to resolve to an object type, but the field's type is something else (scalar, list, or name-only reference). The resolver needs an object type to recurse into nested subfield predicates. It surfaces from the TypePredicateError enum during metadata resolution of filter relationships and boolean expression types.

Source

Thrown at cli/cli.go:235

		return c.AdminSecrets[0]
	} else if c.AdminSecret != "" {
		return c.AdminSecret
	}

	return ""
}

func (c *ServerConfig) GetHasuraInternalServerConfig(client *httpc.Client) error {
	var op errors.Op = "cli.ServerConfig.GetHasuraInternalServerConfig"
	// Determine from where assets should be served
	url := c.getConfigEndpoint()

	ctx, cancelFunc := context.WithTimeout(context.Background(), 30*time.Second)
	defer cancelFunc()

	req, err := client.NewRequest("GET", url, nil)
	if err != nil {
		return errors.E(op, fmt.Errorf("error fetching config from server: %w", err))
	}

	r, err := client.Do(ctx, req, &c.HasuraServerInternalConfig)
	if err != nil {
		return errors.E(op, errors.KindNetwork, err)
	}
	defer r.Body.Close()

	if r.StatusCode != http.StatusOK {
		var horror hasuradb.HasuraError

		err := json.NewDecoder(r.Body).Decode(&horror)
		if err != nil {
			return errors.E(
				op,
				errors.KindHasuraAPI,
				stderrors.New("error unmarshalling fetching server config"),
			)

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Verify the field referenced in the filter predicate is actually an object/relationship field in your metadata
  2. Fix the field's type definition so it points to the intended object type name
  3. If filtering a scalar, use a direct comparison operator instead of a nested predicate
  4. Re-resolve metadata and check earlier errors (e.g. ObjectTypeNotFound) that may cascade into this one

Example fix

// before
{ "field": "author", "where": { "name": { "_eq": 1 } } } // 'author' resolves to scalar
// after
{ "field": "author", "where": { "name": { "_eq": "A" } } } // 'author' is object type User
Defensive patterns

Strategy: validation

Validate before calling

// Before resolving predicates, confirm the field's type is an object
const isObjectField = (meta, typeName, fieldName) => {
  const t = meta.types[typeName];
  const f = t?.fields?.[fieldName];
  return !!f && isObjectTypeRef(f.type);
};
if (!isObjectField(metadata, 'Article', 'author')) throw new Error('author is not an object field');

Type guard

function isObjectTypeRef(t) { return t?.kind === 'TypeReference' || (typeof t === 'object' && t?.type !== undefined && !isScalarName(t.type)); }

Try / catch

try { resolvePredicate(...); } catch (e) { if (e?.code === 'ExpectedObjectType') reportFieldIssue(e.field_name); else throw e; }

Prevention

When it happens

Trigger: Resolving a type predicate for a field whose QualifiedTypeReference resolves to a non-object type (e.g. a scalar or array), typically when a relationship field is declared with an incompatible target type in the metadata, or when using nested 'where' predicates in a command/relationship whose field type cannot be resolved to an object.

Common situations: Relationship metadata pointing at a scalar field; a nested filter argument used on a scalar field in a trackable command; inconsistent type definitions between subgraphs; upgrading metadata versions where a field type changed from object to scalar.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/5bdbf7c7efac67fe. Report an issue: GitHub.