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

Cold Start #257

Open
Quantumplation opened this issue Mar 10, 2024 · 3 comments
Open

Cold Start #257

Quantumplation opened this issue Mar 10, 2024 · 3 comments

Comments

@Quantumplation
Copy link
Contributor

I'd like to add the ability to accelerate startup by specifying an initial schema (loaded from disk, for example) so that queries can start being served immediately in the happy path, while the server checks in the background for updates to the schema.

I tried to add this to the code, but quickly got lost, so I figured I'd open a feature request. If you can provide a touch of guidance for how/where to achieve this, I'd be happy to submit a pull request.

@pkqk
Copy link
Member

pkqk commented Mar 11, 2024

Hi @Quantumplation,

It will require quite a few changes probably, like in your discussions on #231.

I would start with adding something parallel to UpdateSchema that can load a serialized schema and save one to storage periodically.

Then change the startup in Main to trigger that first before starting the periodic update goroutines.

@Quantumplation
Copy link
Contributor Author

That's where I started, but I wasn't sure how to construct an ExecutableSchema from a string; we make a bunch of requests to other services, and then rebuild the merged schema from the ASTs, but I don't see where the ASTs get built from raw text.

@pkqk
Copy link
Member

pkqk commented Mar 14, 2024

Have you looked through the gqlparser library, it's mostly in there, it doesn't have many helper methods but you can read schema sources into a string and then use something like:

gqlparser.MustLoadSchema(&ast.Source{Input: str})

to get an *ast.Schema.

The initial creation of ExecutableSchema is in Config.Init so it might be more fitting to put the (de)serialisation there.

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