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

Pregenerate and Caching GraphqlSchema with Pickle #222

Closed
vt-rc opened this issue Aug 12, 2024 · 4 comments
Closed

Pregenerate and Caching GraphqlSchema with Pickle #222

vt-rc opened this issue Aug 12, 2024 · 4 comments

Comments

@vt-rc
Copy link

vt-rc commented Aug 12, 2024

I am running graphene-django on serverless
I am posting here because Schema loading is in GraphqlSchema.

often time when there is cold start and the cold start is very slow because the schema loading is very slow, 1xx+ms for a fairly small schema. For larger service the schema load time can be over 3xx-4xx+ms

(please don't tell me to stop running serverless, thx)

I am trying to pregenerate and cache the Schema for production environment,

I tried to pickle the schema because I saw #173 , but it isn't working. I am getting the error
Can't pickle local object 'TypeMap.create_objecttype.<locals>.interfaces

Or are there other way to speed up start time? Maybe write it in another language as extension?

@Cito
Copy link
Member

Cito commented Aug 12, 2024

Pickling schemas should work and is tested as part of the test suite since GraphQL-core 3.3.0a2. Probably you're using an older version of GraphQL-core.

@vt-rc
Copy link
Author

vt-rc commented Aug 12, 2024

I just upgraded and now I am getting this error

pickle.dump(self.graphql_schema, f)

_pickle.PicklingError: Can't pickle <XxxxxNodeConnection meta=<ConnectionOptions name='XxxxxNodeConnection'>>: attribute lookup XxxxxNodeConnection on graphene.types.objecttype failed

@Cito
Copy link
Member

Cito commented Aug 12, 2024

Looks like this happens because the Graphene schema wrapper or some types created by it cannot be pickled. Unfortunately this cannot be solved here. The Graphene project would be the right place to ask for help.

@vt-rc
Copy link
Author

vt-rc commented Aug 13, 2024

Thank you so much for your prompt reply. You are wonderful!!!

@vt-rc vt-rc closed this as completed Aug 13, 2024
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