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

QueryNameVariables type enforces runtime scalars to be present in the return value when they are not required #1308

Open
ewen-lbh opened this issue Jun 22, 2024 · 0 comments

Comments

@ewen-lbh
Copy link
Contributor

ewen-lbh commented Jun 22, 2024

Describe the bug

Currently, the (query name)Variables type, exported from ./$houdini, requires the return type to contain values for variables that are defined with runtime scalars, even though not defining them works.

For example, take the following query document, with FooScalar a runtime scalar:

query Example($a: FooScalar!, $b: String!, $c: Boolean) {
   foo, bar
}

In a +page.ts file:

import { type ExampleVariables } from './$houdini';

//                                                        v~~ Missing property "a" in return type
export const _ExampleVariables: ExampleVariables = async () => ({ b: "spam", b: true })

Workaround

We are currently hardcoding a list of runtime scalars (we juste have one for the moment), and re-defining the type using VariablesFunction:

https://github.com/inp-net/churros/blob/c801d54925f5f056f37a302b0dd4f40600d9b6e5/packages/app/src/lib/typing.ts#L16-L24

...and using them accordingly:

https://github.com/inp-net/churros/blob/c801d54925f5f056f37a302b0dd4f40600d9b6e5/packages/app/src/routes/(app)/%2Blayout.ts#L7

I'll set up a repro link later if it's necessary.

Since runtime scalars are a gated feature, I guess this could be expected, but accomodating for this would lead to a better DX. I may have time to work up a PR sometime around the end of next week

Reproduction

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant