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

How to support HMR with Pothos #1199

Open
AndrewIngram opened this issue May 10, 2024 · 2 comments
Open

How to support HMR with Pothos #1199

AndrewIngram opened this issue May 10, 2024 · 2 comments

Comments

@AndrewIngram
Copy link

I couldn't find any examples of this, so testing the waters a bit. We have a pretty huge module graph, to the point that process starts/restarts take a long time. So I started looking into using chokidar to purge modules from the import cache, it was working pretty well but I hit a wall with Pothos.

It seems the builder pattern is a little at odds with what I'm trying to achieve, because if a module with some gql types in is re-executed, Pothos will error.

I can't see a current workaround, but I'm wondering how viable it is to somehow support putting the builder into a mode which allows redefinition of types in a robust way.

@hayes
Copy link
Owner

hayes commented May 10, 2024

Yeah, this is definitely not easy with the builder pattern. I don't know how your invalidation works, but the pattern used here: https://github.com/hayes/svelekit-graphql-test/blob/main/src/graphql/builder.ts. would be a good place to start.

Basically, if you dynamically import the file that generates the schema into the builder class (this creates a circular dependency).

The effect if this is that, the file that build the schema generally needs to import every file that makes up the schema, so it will become invalidated when anything in the schema changes. Normally the file that creates the builder would not be invalidated, but if it has a dynamic import of the build schema, it should also be invalidated, which should end up re-building the entire schema on every change. Obviously this isn't perfect, but its the best option I have come up with for this sort of builder pattern

@AndrewIngram
Copy link
Author

Interesting, I'll give that a try

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

2 participants