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
.cook() is not idempotent #256
Comments
.cook() (and the global process of creating an engine) is meant to be done once. But you won't be able to do 2 engine with the same SDL if schema_name is the same. |
I think the first step of implementing a 'cooked' state is easily doable. |
That makes sense. But then I'm thinking about people using |
FYI I pushed a branch with failing tests in tartiflette/tartiflette-asgi#35. |
I see your point, yeah maybe a SchemaRegistry.clean() could also be a cool idea. It would save the time of creating a new Engine/App with a |
Thank you @florimondmanca. I'll make the release tomorrow. |
Great, thanks! 🚀 |
.cook()
multiple times without it failing with hard-to-debug error tracebacks.More details
While playing with tartiflette/tartiflette-asgi#32 I ran into issues when
.cook()
was being called multiple times. (I need to to this because we can't create anEngine
multiple times in the same session, and so one singleEngine
is reused across tests.)Ultimately, here are the reasons why I think this doesn't work:
.cook()
tries to import modules, althoughself._modules
might already contain the importedmodule
objects from a previous call. Overall I think this (and potentially other issues) can be fixed by adding a simple._cooked
flag and skipping.cook()
if it'sTrue
..cook()
always registers the SDL, even though it may have already been added to theSchemaRegistry
before, which fails on second time because the same SDL is used, resulting in conflicting types. (I suppose this is why we use aclean_registry
in the engine unit tests.) I don't really have an idea on how to fix this. Should I just clean the registry like we do in the tests before calling.cook()
intartiflette-starlette
?The text was updated successfully, but these errors were encountered: