Use Fragment in Query #10211
Unanswered
hellofrontendxxx
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using fragment for query, but it is not working
When I use the code below it gives me this error
export const CURRENT_USER_FRAGMENT = graphql(
fragment CurrentUserItem on CurrentUser { id }
);export const GET_CURRENT_USER_TEST = graphql(
query GetCurrentUserTest { me { ...CurrentUserItem } }
);Property 'id' does not exist on type '{ __typename?: "CurrentUser" | undefined; } & { ' $fragmentRefs'?: { CurrentUserItemFragment: CurrentUserItemFragment; } | undefined; }'.
But when i use this code it works as expected
export const GET_CURRENT_USER_TEST = graphql(
query GetCurrentUserTest { me { id } }
);I can log data?.me?.id
Please help me, thanks everyone
Beta Was this translation helpful? Give feedback.
All reactions