Skip to content
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

Refetchable fragments #129

Open
AlecAivazis opened this issue Jul 9, 2021 · 2 comments
Open

Refetchable fragments #129

AlecAivazis opened this issue Jul 9, 2021 · 2 comments
Labels
Core Issues related to the core infrastructure Enhancement A new feature or improvement to Houdini's public API

Comments

@AlecAivazis
Copy link
Collaborator

AlecAivazis commented Jul 9, 2021

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 })
    }
}
@AlecAivazis AlecAivazis added the Enhancement A new feature or improvement to Houdini's public API label Jun 24, 2022
@jycouet
Copy link
Collaborator

jycouet commented Jul 17, 2022

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?

@AlecAivazis
Copy link
Collaborator Author

AlecAivazis commented Jul 18, 2022

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 🤔

@AlecAivazis AlecAivazis added SvelteKit Issues related to the SvelteKit integration Router Issues related to the React framework Core Issues related to the core infrastructure and removed SvelteKit Issues related to the SvelteKit integration Router Issues related to the React framework labels Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Issues related to the core infrastructure Enhancement A new feature or improvement to Houdini's public API
Projects
None yet
Development

No branches or pull requests

2 participants