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

[4.x]: GraphQL schema is no longer lazy loaded #15429

Closed
markhuot opened this issue Jul 26, 2024 · 4 comments
Closed

[4.x]: GraphQL schema is no longer lazy loaded #15429

markhuot opened this issue Jul 26, 2024 · 4 comments

Comments

@markhuot
Copy link
Contributor

What happened?

Description

The entire GraphQL schema is read in on every request, regardless of the query complexity or query needs. Because of this our web requests are rather slow (1.5s instead of 500ms). This adds up when you have a headless front-end making 3-4 requests per page.

I believe I've identified the reason for this, here: b9d8ec5

Steps to reproduce

  1. Submit a GraphQL query for {ping}.
  2. Notice that every matrix block is queried, every entry type is queried, etc… via the DB query log

Expected behavior

The schema should be lazy loaded, where possible.

Actual behavior

The entire schema is read every time.

Notes

I'm not sure how realistic is to reverse this decision or if there could be a config for it? Basically wondering what sort of issues I'd run in to if I tried to force a lazy schema.

Craft CMS version

4.9.5

PHP version

8.3.4

Operating system and version

Ubuntu

Database type and version

MySQL 8

Image driver and version

n/a

Installed plugins and versions

No response

brandonkelly added a commit that referenced this issue Jul 27, 2024
@brandonkelly
Copy link
Member

Thanks for pointing that out. On second look, the problematic query in #13622 could have been solved by putting the fragment after the main query, so I probably should have just recommended doing that.

I can’t revert the change without potentially breaking things at this point, but I did just add a new lazyGqlTypes config setting for 4.11 + 5.3, which you can enable to revert to the previous behavior. (4d805f4)

@markhuot
Copy link
Contributor Author

Thanks @brandonkelly! This is great and exactly what we needed.

@markhuot
Copy link
Contributor Author

Note: I tried updating my composer.json to 4.x as 4.11.0 and running composer update but I'm getting Fatal error: Uncaught Error: Class "Yii" not found in…. Probably my issue though? Is there any reason the 4.x branch shouldn't work?

@brandonkelly
Copy link
Member

@markhuot Sorry, that’s fixed now (a2bdfbf). Bug introduced by #15346 that only affects installs that are still returning an array from their config/general.php or config/db.php files. I forgot the feature is coming to Craft 4.11, so I had fixed it for the 5.3 branch but not 4.11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants