HoudiniGraphql / houdini

The disappearing GraphQL framework
http://www.houdinigraphql.com
MIT License
897 stars 95 forks source link

Passing parameters to headers #206

Closed dxlbnl closed 2 years ago

dxlbnl commented 2 years ago

I'm using hasura which requires some information to be passed to the header for some specific queries. Now it's possible to write to the session in an onmount, and cleaning the session onDestroy, its not so clean and the whole session needs updating.

I'd like a query to be able to pass some data to a query where I could set it to the right place with the environment call

AlecAivazis commented 2 years ago

Hey @neoel! Sorry for not replying sooner, I'm trying to think of the right way to support this. Do you have any recommendations for the api?

dxlbnl commented 2 years ago

Possibly a context object to be passed to query and mutation:

const { data } = query(graphl``, {
  contextParam: 'value'
})

Inside environment we could get this context param and apply it wherever necessary.

jycouet commented 2 years ago

It would be like metadata that users can send per query? Like this, users will make use of it in their own fetchQuery?

AlecAivazis commented 2 years ago

@jycouet since we mention this as a good usecase for the store API, we should make sure its actually possible 😅 Thoughts on including this in 0.15.0?

jycouet commented 2 years ago

Yeah, seems reasonable to add it. Just, let's NOT name it context (we already have 42 😅)

I can have a look. We go with metadata?

jycouet commented 2 years ago

It's in https://github.com/HoudiniGraphql/houdini/pull/344 🥳 I will let you close @AlecAivazis when it's deployed? (even under a -next-xx version)

AlecAivazis commented 2 years ago

🎉 It's now been published as part of 0.15.0-next.13