#14927·amplify-js

Support selectionSet in custom queries, mutations, and subscriptions

Author: sot1986Created Aug 30, 2026Updated Sep 3, 2026
Labelsfeature-requestData

Is this related to a new or existing framework?

Vue

Is this related to a new or existing API?

GraphQL API

Is this related to another service?

No response

Describe the feature you'd like to request

In architectures utilizing Single Table Design or complex backend logic, standard model CRUD operations (client.models.*) often do not fit the required access patterns. Instead, developers rely on custom queries and mutations (client.queries.*, client.mutations.*, client.subscriptions.*) backed by custom AppSync JavaScript resolvers or Lambda handlers. Currently, client.models.* supports the selectionSet option (e.g. { selectionSet: ['id', 'title'] as const }), allowing fine-grained GraphQL field selection and automatic TypeScript type narrowing on the response. However, custom operations generated from a.schema() definitions currently lack selectionSet support in their options argument. This forces developers to fall back to untyped, raw client.graphql({ query: '...' }) strings whenever they want to take full advantage of GraphQL's selective over-the-wire fetching on custom resolvers.

Describe the solution you'd like

Add selectionSet support to custom operations options:

  1. Allow { selectionSet: ['field1', 'field2'] as const } on custom queries, mutations, and subscriptions returning models or non-models.
  2. Narrow TypeScript return types based on the requested selectionSet.
  3. Fall back to the default full selection set when selectionSet is omitted or undefined.
  4. Omit selectionSet from options when the operation returns a primitive scalar or enum.

Use Case & Motivation

Allows developers using Single Table Design and flexible custom resolvers to request only the fields needed by their UI views with full type safety and zero over-fetching, matching the DX of standard model operations.

Area

API / GraphQL / Data Client Gen 2

Describe alternatives you've considered

Keep fetching all graphql output.

Additional context

No response

Is this something that you'd be interested in working on?

  • I may be able to implement this feature request
  • ⚠️ This feature might incur a breaking change