Replies: 1 comment 3 replies
-
How about you merge the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The library recommends storing the parsed AST on disk as a loadable PHP file that can be loaded and passed to
BuildSchema::build
which generates a lazy-loaded schema. However this causes challenges when combined with a set-up that makes use ofextend type
.Below are the two non-ideal methods that I know of, one doesn't work and another has a transformation that feels unnecessary. What is the correct way to do
AST::toArray($schema)
to allow restoring a merged schema later withAST::fromArray
?Storing the concatenated parsed AST
One option which seems sensible is to parse all individual documents and use
AST::concatAST
over the array. This results in a merged AST that could be passed toBuildSchema::buildAst
. The problem is thatBuildSchema::buildSchema
does not handleextend
type nodes, so this results in a schema that only has the base fields.Using SchemaExtender::extend
This is the preferred method to apply these kinds of extensions. Fetching the AST that contains the extension separately is easy enough and it's even possible to cache this to disk with
AST::toArray
. However the method itself will load all types in the schema that's being extended which is a very slow operation, so this makes it unusable in production.The goal is then to get a resulting AST from the merged schema. The only way that I'm aware of to get an AST from a schema and write it to disk is to run
AST::toArray(Parser::parse(SchemaPrinter::doPrint($schema)))
. However it feels weird to go through text this way and not being able to get the AST from the schema directly without going through SDL.Beta Was this translation helpful? Give feedback.
All reactions