You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing an inline fragment to be used by readInlineData, Relay won't warn you if you forget to use the @inline directive:
exportfunctiongetFooBarValue(fragmentRef: DummyExampleFragment$key){constdata=readInlineData(graphql` fragment DummyExampleFragment on Node { ... on Foo { bar } } `,fragmentRef,);returndata?.foo?.bar??"";}
From the compiler standpoint, everything works great as long as you spread DummyExampleFragment on Node. However, at runtime, Relay will throw an error:
Invariant Violation: GraphQLTag: Expected an inline data fragment, got `{"argumentDefinitions": ... }`.
The fix is simple - we just need to add @inline to our fragment definition. It would be great if the compiler explained that to me at build-time.
Overall, I believe we need "smarter" fragment types. Typescript should complain if:
I pass a fragment without @refetchable to useRefetchableFragment
I pass a fragment without @inline to readInlineData
I pass a fragment without @connection and @refetchable to usePaginationFragment
etc.
The text was updated successfully, but these errors were encountered:
When writing an inline fragment to be used by
readInlineData
, Relay won't warn you if you forget to use the@inline
directive:From the compiler standpoint, everything works great as long as you spread
DummyExampleFragment
onNode
. However, at runtime, Relay will throw an error:The fix is simple - we just need to add
@inline
to our fragment definition. It would be great if the compiler explained that to me at build-time.Overall, I believe we need "smarter" fragment types. Typescript should complain if:
@refetchable
touseRefetchableFragment
@inline
toreadInlineData
@connection
and@refetchable
tousePaginationFragment
The text was updated successfully, but these errors were encountered: