Input design for queries and mutations
This standard defines the input structure for all queries and mutations in our GraphQL APIs: a single input object with consistent filtering, search, sorting, and pagination.
The problem
Without a standard structure, each query invents its own way of passing parameters and the API becomes inconsistent, difficult to use, and hard to maintain as it grows. The typical symptoms:
- Inconsistent parameter passing conventions across queries.
- Filtering and sorting that don't scale to complex cases.
- Poor discoverability of the available options.
- Difficult version management.
- An input structure that is hard to document.
The solution: a standardized input object
All queries and mutations wrap their parameters in a single input argument with a consistent structure:
- Root input object: all parameters are passed via a single
inputargument. - Identifier fields: resource identifiers (for example
organizationId,userId) are direct properties of the input. filterobject: nested object for filtering, with consistent operators.searchobject: structured search parameters.sortarray: standard sorting mechanism.paginationobject: consistent pagination controls.
Mandatory requirements
Every new query and mutation schema design meets these requirements:
- Single input: always use a single parameter named
inputthat accepts an input object. - Consistent naming: every input type ends with the
Inputsuffix (for example,ATSListJobApplicantInput). - Standard operators: use consistent operator suffixes for filtering:
_eq,_neqfor equality_gt,_gte,_lt,_ltefor comparisons_in,_ninfor array inclusion or exclusion
- Pagination: every list query supports standard pagination.
- Sorting: every list query supports sorting by its relevant fields.
- Search: where applicable, implement the standard search pattern.
- Identifier fields: entity identifiers always go as top-level fields of the input object.
- Documentation: every input field carries its description.
Schema definition
Usage examples
List job applicants
With these variables:
Product search
With these variables:
Advantages and disadvantages
The pattern trades verbosity for consistency.
Advantages:
- Consistency: uniform structure across all queries and mutations.
- Scalability: easily extensible with new filtering options without breaking changes.
- Discoverability: clear patterns make it easier to guess which options exist.
- Maintainability: consistent patterns simplify API maintenance.
- Documentation: the expected input format is easier to document and understand.
- Evolution: the API evolves gradually without breaking clients.
- Less boilerplate: pagination and sorting are standardized.
Disadvantages:
- Verbosity: more verbose than simple parameter passing for simple queries.
- Learning curve: new team members need to learn the pattern conventions.
- Implementation complexity: the backend needs more code to handle the flexible structure.
- Performance: generic filtering can be less performant than a specialized query.
- Schema size: the GraphQL schema documentation can grow.

