-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lack of the type of ‘total’ property in GraphQLResult if using searchXxx query #13766
Comments
Hi @HikaruTakakura can you share your schema? |
Thank you for your prompt reply. This is my schema.
|
@HikaruTakakura hmm, I don't think that we support a |
@chrisbonifacio Thanks for the information. However, the issue I am raising is not the implementation of the Here is the query and its type generated by the schema shown above. // queries.ts
export const searchCats = /* GraphQL */ `query SearchCats(
$filter: SearchableCatFilterInput
$sort: SearchableCatSortInput
$limit: Int
$nextToken: String
$from: Int
) {
searchCats(
filter: $filter
sort: $sort
limit: $limit
nextToken: $nextToken
from: $from
) {
items {
// ...
}
nextToken
total
__typename
}
}
` as GeneratedQuery<
APITypes.SearchCatsQueryVariables,
APITypes.SearchCatsQuery
>; // API.ts
export type SearchCatsQuery = {
searchCats?: {
__typename: "SearchableCatConnection",
items: Array< {
__typename: "Cat",
// ...
} | null >,
nextToken?: string | null,
total?: number | null,
} | null,
}; It is clear that the response to the query should contain a So now we use |
Hi @HikaruTakakura 👋 thanks for raising this issue! I was able to get import { SearchCatsQuery } from "@/src/API";
import { searchCats } from "@/src/graphql/queries";
import { GraphQLQuery } from "aws-amplify/api";
// ...
const searchCatsQuery = async () => {
const result = await client.graphql<GraphQLQuery<SearchCatsQuery>>({
query: searchCats,
}) |
Hi @chrisbonifacio thank you very much. |
@HikaruTakakura re-opened this issue and will discuss with the team! In the meantime, please submit a Pull Request with the proposed fix for the team to review |
Hi @HikaruTakakura, just wanted to follow up on this. Would you still like to submit a pull request for this? In the meantime, I'm going to mark this as a feature request |
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
GraphQL API
Amplify Version
v6
Amplify Categories
api
Backend
Amplify CLI
Environment information
Describe the bug
Property total does not exist on type 'PagedList<{ __typename: "Cat"; ...'.
The reason is that
WithListsFixed<T>
removes properties that exist inT
but are not included inPagedList
.amplify-js/packages/api-graphql/src/types/index.ts
Line 105 in ced891c
In fact, the error disappeared after making the following changes
Expected behavior
The total property exists, so there should not be an error
Reproduction steps
searchCats
) using@searchable
.const response = await client.graphql({ query: searchCats })
response.data.searchCats
Code Snippet
No response
Log output
No response
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: