aws-amplify / aws-amplify/amplify-data
Native support or docs for Tanstack React Query/Orval
- Dominant language
- TypeScript
- Stars
- 18
- Forks
- 23
- Avg merge
- 26m
- Merged PRs (30d)
- 1
Description
### Environment information
```plain text
-
```
### Description
[Orval](https://orval.dev/guides/react-query) is a wrapper around [Tanstack React Query](https://tanstack.com/query/v4/), auto-generated from an OpenAPI spec.
It would be fantastic and lead to much cleaner React Web & Native code if we could auto-generate hooks to access our data and manage loading, error states, instead of manually having to deal with `useEffect` and `useState`.
Here is what it would look like with an Orval-like interface:
```
import { useGetBookDetails } from '@/...';
interface Props {
bookId: string;
}
export const MyComponent = ({ bookId }: Props) => {
const { data: bookDetails, isLoading, error } = useGetBookDetails({ bookId });
return (<>
{isLoading && }
{error && {error.message}}
{bookDetails &&
{bookDetails.title}
});
}
```
Although something like this could also work and would avoid code generation:
```
interface Props {
bookId: string;
}
export const MyComponent = ({ bookId }: Props) => {
const { data: bookDetails, isLoading, error } = useQuery(
() => client.models.Book.get({ id: bookId });
);
return (<>
{isLoading && }
{error && {error.message}}
{bookDetails &&
{bookDetails.title}
});
}
```
Contributor guide
Research direction
Start by reading the linked Orval React Query guide and TanStack React Query documentation, then compare the two proposed approaches in the issue examples. Determine whether the project needs native support, documentation, or both, and define a concrete integration path with a clear example of generated hooks or useQuery usage as the completion criterion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, react, react-native, typescript
- Domain
- api, frontend, mobile-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100