Skip to content

idea: allowing the query and options args to be reactive. #5

@trusktr

Description

@trusktr

For example,

const [query, setQuery] = createSignal(makeQuery(...args))
const data = createQuery(query, options)

createEffect(() => {
  console.log(data())
})

// later
// disposes the previous query internally, makes a new one with the new query document.
// the effect will re-run with the new result eventually
setQuery(makeQuery(...otherArgs)) 

One reason for this is I find it too cumbersome to write query variables. So this is much easier in various cases:

function makeQuery(foo: string, bar: string) {
  return gql`
    query SomeQuery {
      someStuff("${foo}", ${bar}) {
        foo
      }
    }
  `
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions