api-platform / api-platform/core

Discussion: GraphQL performance issues

Offen
#7,980 5 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen
GraphQL
Vorherrschende Sprache
PHP
Sterne
2.6k
Forks
980
Ø Merge
2 T. 5 Std.
Gemergte PRs (30 T.)
48

Beschreibung

so, i've been digging a little bit and stumbled over the SchemaBuilder, which makes up quite a significant portion of GraphQL requests (Blackfire example: http://img.mia3.com//?i=BChcGpHy1ouvUeKc.png)

Imho, this should be cached/cachable, right? I already tried some approaches and realized, that it's not that easy because of the Closures used for [resolveType](https://github.com/api-platform/core/blob/master/src/GraphQl/Type/SchemaBuilder.php#L122) and [fields](https://github.com/api-platform/core/blob/master/src/GraphQl/Type/SchemaBuilder.php#L412).

The resolveType could be replaced by a static function instead of a closure, but the fields is a bit trickier. I tried to replace the closure with the direct result of the internal getResourceObjectTypeFields method call, sadly, this turns into a recursive loop, because the related objectTypes are not registered yet at this point.

I have 2 Ideas how this whole thing could be approached:

1. somehow fix the recursive issue, maybe by registering the objectType first and "override" the fields after the object itself was resolved
2. Rewrite most of the SchemaBuilder to generate a "cached" Schema.php file that contains everything and is simply included on load.

Is there another way i'm maybe not seeing?

Cheers
Marc

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.