-
-
Notifications
You must be signed in to change notification settings - Fork 438
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
Cacheable schema manipulation via directives #140
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…pe safety and prevent typos
…pe safety and prevent typos
…ator-directives # Conflicts: # docker-compose.yml # src/Schema/Directives/Fields/PaginateDirective.php # src/Schema/MiddlewareManager.php # src/Schema/SchemaBuilder.php # src/Schema/Utils/DocumentAST.php # src/Support/Contracts/SchemaGenerator.php # src/Support/Traits/CreatesPaginators.php
…erator to SchemaManipulator
…e interface for FieldManipulator and NodeManipulator
The node field must only be added if it is implemented by another type, otherwise the schema is not valid
…ator-directives # Conflicts: # src/Schema/CacheManager.php # src/Schema/SchemaBuilder.php
… returns without "Node" at the end)
- This is because it is often useful to only run Unit tests first, since the Integration tests almost all fail if a single mistake happens - Found & fixed a bug where the static attributes on DocumentValidator, set in SecurityTest, influence the execution of all other tests
- This actually validates that test queries are valid - Found & Fixed a few test queries that were invalid
- Properly indent all schema definitions and queries - Clean up whitespace - Fix some Doc Blocks - Add comments - Remove unused methods
Monumental effort, exciting stuff here! |
[WIP]: Revert structural changes
…ve autocompletion
This was referenced Jun 25, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR rebuilds how Lighthouse deals with schema manipulation.
Reasoning
Directives can now implement an Interface that marks them as schema-manipulating. This manipulation is executed directly on the AST. This has multiple benefits:
In the spirit of 'schema-first', this also enables full utilization of the SDL.
The final schema can be validated and printed before using it in production.
Users can use the output for documentation, mocking or static query analysis.
This also opens the door for more complex schema manipulation. The features proposed in #131 and #84 would greatly benefit from this.
Bugfixes
Coincidentally, i found and fixed a bug that prevented middlewares being applied in some cases, this might resolve the Issues #134 and #121
Backwards compatibility
I made sure to keep most of the tests as they were before to ensure we do not break existing use-cases. While the inner workings where changed quite a bit, the functionality of the directives should be the same as before.
Caching now uses Laravels Cache Facade. To enable caching, a new configuration option was added. Users that have the previous configuration will not get caching for their AST but can easily update their config to enable caching.
Breaking changes
Custom directives will have to be changed. All directives have to implement a common Interface. Schema manipulation should only happen by implementing the respective Manipulator interface:
ManipulateType
,ManipulateField
andManipulateArg
Some internal classes were shifted around so users that reach directly into our source might have to change their code as well. This should not be a big issue as we haven't formally specified a public API yet.