-
-
Notifications
You must be signed in to change notification settings - Fork 267
Support class based schemas #706
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
Conversation
Not sure why the static analysis is failing. I didn't touch routes.php. Looks like it fails on master too. 🤔 🤷 |
Hey @jasonvarga , thanks for the PR! I'll check it out as soon as I find time, might take a while though. I wouldn't worry yet about the analyzer, I'll check this out later too. |
Thanks! |
# Conflicts: # CHANGELOG.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, LGTM!
Also nice job with statamic/cms#2982 😱
Will merge & release as soon as everything is green
Awesome, thanks! |
Summary
This PR adds support for defining a class based schema.
Rather than defining the entire schema directly in the config file, like this:
You'll be able to define it by specifying a class name:
This class should implement the new
ConfigConvertible
contract which will convert to an array you'd have previously used in the config file.The reason this would be useful for us (Statamic, a Laravel CMS package) is because we intend to be able to have an entire schema that users can put into their config. We don't want them to have to manually define the config.
Also, we intend to allow third parties to inject their own query classes into our schema. The schema class above is a bit simplified. Ours might look more like this:
I'm not quite sure how you feel about the naming of things here though. I used
ConfigConvertible
andtoConfig()
because I saw aTypeConvertible
interface withtoType()
.The only technically breaking change here is that if you already used a string, you'd previously get a GraphQL error like
cannot query field "some_query"
and now you'd get aBindingResolutionException
. But your app wouldn't have been working in the first place so I don't think it really matters.Type of change
Checklist
composer fix-style