redwood: Typescript - rename not working in ts
follow the tutorial, i rename the posts to articles, but the eslint yell at me
import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web'
import { FindPosts } from 'types/graphql'
export const QUERY = gql`
query ArticlesQuery {
articles: posts {
id
title
body
createdAt
}
}
`
export const Loading = () => <div>Loading...</div>
export const Empty = () => <div>Empty</div>
export const Failure = ({ error }: CellFailureProps) => (
<div style={{ color: 'red' }}>Error: {error.message}</div>
)
export const Success = ({ articles }: CellSuccessProps<FindPosts>) => {
return (
<>
{articles.map((article) => (
<article key={article.id}>
<header>
<h2>{article.title}</h2>
</header>
<p>{article.body}</p>
<div>Posted at: {article.createdAt}</div>
</article>
))}
</>
)
}
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 15 (13 by maintainers)
@jtoar codegen checks the web side as well and generates the type for each GraphQL operation.
And I finally see why it’s not working.
@PeterChen1997 type needs to change from
CellSuccessProps<FindPosts>toCellSuccessProps<ArticlesQuery>. Since the type name is the same as whatever is set for the operation name. If we usequery SomeOtherName, we need to update the type name.