houdini
houdini copied to clipboard
Refetchable fragments
There should be a @refetchable directive that labels fragments on Node or Query as refetchable. The api could look something like this:
const { data, refetch, variables } = refetchableFragment(graphql`
fragment UserFragment on User @refetchable @arguments($filter: { type: "String" }) {
field(filter: $filter)
}
`)
const filter = writable("")
$: {
if ($filter) {
refetch({ filter: $filter })
}
}
As we have now a Fragment store where we can .get(), we could probably add another function: .refetch()
Is there the need to explicitly set @refetchable?
not every fragment is refetchable, it has to be defined on a type that either extends Node or has a custom type resolution defined. @refetchable would act as a mark to the artifact generator that it needs to generate the appropriate queries and verify the config.
edit: If the queries were computed at runtime, we might be able to do away with it 🤔