aws-amplify / aws-amplify/amplify-data

selectionSet in custom mutations or queries

Open
#444 0 comments 1 reaction 0 assignees View on GitHub
data-schema feature-request
Dominant language
TypeScript
Stars
18
Forks
23
Avg merge
26m
Merged PRs (30d)
1

Description

### Describe the feature you'd like to request

It will be better if we have **`selectionSet`** in custom mutations or queries.

### Describe the solution you'd like

Same like in list we have **`selectionSet`**. If we can do this in custom mutations and queries, it will be better to fetch only data that we want.

```javascript
const { data, errors } = await $Amplify.GraphQL.client.mutations.CreatingTodo(TodoDetail.value, {
selectionSet: [
'id',
'title',
],
authMode: 'userPool',
});
```

### Describe alternatives you've considered

Currently we get all values that we added in custom mutation in **`.returns(a.ref('Todo'))`** in data resource.

### Additional context

_No response_

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

- [X] 👋 I may be able to implement this feature request

### Would this feature include a breaking change?

- [ ] ⚠️ This feature might incur a breaking change

Contributor guide

Open the contributing guide

Research direction

Start by tracing how selectionSet is implemented for list operations, then compare that path with custom mutation and query calls using .returns(a.ref('Todo')). Confirm how the requested selectionSet should flow through both operation types, and consider the example’s id and title fields as the completion case.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.