Summary
buildGraphQLSchema documents that an out-of-range perPage "is rejected with a clear error instead of reaching the engine". It is rejected, but the client sees Unexpected error. with INTERNAL_SERVER_ERROR, so there is nothing to act on.
Reproduction
search-api-server:0.7.0, maxPerPage at its default of 100:
{ creativeWorks(perPage: 101) { pagination { total } } }
{ "message": "Unexpected error.",
"extensions": { "code": "INTERNAL_SERVER_ERROR" } }
Identical for perPage: -1 and page: 0. perPage: 0 is accepted, correctly – it is the facet-only query.
Likely cause
The bound check throws a plain Error, and Yoga masks anything that is not a GraphQLError behind Unexpected error. to avoid leaking internals. Throwing a GraphQLError (optionally extensions.code: 'BAD_USER_INPUT') would surface it unmasked, since the message is deliberately client-facing.
Why it matters
The bound is not discoverable: it is not in the SDL, and introspection shows only perPage: Int. A client that guesses too high gets a message indistinguishable from a server fault – the natural next step is to retry, or to report an outage. Naming the limit in the error ("perPage must be between 0 and 100") makes it self-correcting.
Summary
buildGraphQLSchemadocuments that an out-of-rangeperPage"is rejected with a clear error instead of reaching the engine". It is rejected, but the client seesUnexpected error.withINTERNAL_SERVER_ERROR, so there is nothing to act on.Reproduction
search-api-server:0.7.0,maxPerPageat its default of 100:{ creativeWorks(perPage: 101) { pagination { total } } }{ "message": "Unexpected error.", "extensions": { "code": "INTERNAL_SERVER_ERROR" } }Identical for
perPage: -1andpage: 0.perPage: 0is accepted, correctly – it is the facet-only query.Likely cause
The bound check throws a plain
Error, and Yoga masks anything that is not aGraphQLErrorbehindUnexpected error.to avoid leaking internals. Throwing aGraphQLError(optionallyextensions.code: 'BAD_USER_INPUT') would surface it unmasked, since the message is deliberately client-facing.Why it matters
The bound is not discoverable: it is not in the SDL, and introspection shows only
perPage: Int. A client that guesses too high gets a message indistinguishable from a server fault – the natural next step is to retry, or to report an outage. Naming the limit in the error ("perPage must be between 0 and 100") makes it self-correcting.