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

Artifacts type files should get generated with imports for custom data types #1135

Open
SeppahBaws opened this issue Jul 25, 2023 · 2 comments
Labels
Core Issues related to the core infrastructure Enhancement A new feature or improvement to Houdini's public API

Comments

@SeppahBaws
Copy link
Collaborator

Describe the feature

When a query is generated with a field that uses custom data types, the generated MyQuery.d.ts file doesn't contain the import to that type and TypeScript isn't 100% sure on what to do with it, and doesn't provide auto-complete on the type.
Additionally, if we have a field e.g. of type Temporal.Instant | null, TypeScript will handle it as any.

Manually placing an import type { Temporal } from "@js-temporal/polyfill"; makes TypeScript happy again.

The config should probably have an additional property on the custom scalar to define an import for said type, so that this is done correctly when the type is generated.

(I think I saw this discussed somewhere before, perhaps on the Discord server, but I can't find it anymore so I'm making this issue to keep track of it 🙂)

Criticality

cool improvement, my projects will benefit from it

@AlecAivazis
Copy link
Collaborator

Thanks for opening this! I think where we left off is this:

We could accept and string or an object. treat strings like global types and then make users pass an object that looks like { module: string, type: string } if they want to do something different.

How does that sound to you?

@SeppahBaws
Copy link
Collaborator Author

I think this is a good way to solve it. Might want to hear from some more people on what sort of types they might want to import.

One thing though is e.g. if we have two custom scalars importing two different types from the same package, do we want to do

import type { TypeA } from "@some/package";
import type { TypeB } from "@some/package";

or can we squash them together:

import type { TypeA, TypeB } from "@some/package";

or do we simply not care?

Not entirely sure off the top of my head if typescript will complain about importing from the same package again.

@AlecAivazis AlecAivazis added Enhancement A new feature or improvement to Houdini's public API Core Issues related to the core infrastructure labels Sep 23, 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