-
Notifications
You must be signed in to change notification settings - Fork 44
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
Read Schema from Doctrine Annotations #38
Comments
This sounds like a pretty cool idea. Just curious though, are you imagining a situation where the annotations for a schema are read on the fly (eg. serialization |
I would think it would be read on the fly, no need to create a static schema file if annotations can be easily cached. |
I'm in the early stages of GraphQL, right now just experimenting with creating a schema that replicates our REST API. Having created a handful of inline fields/objects and I'd be happy to start working on this feature after I get past the initial experimentation / proof of concept stage. Any thoughts on the annotation naming convention? If it's possible, it would be awesome to piggyback the |
I envisioned using Doctrine's existing annotations and just having extra annotations when necessary. This would be really convenient for people who use Doctrine already. Then again, if someone isn't using Doctrine (or SensioFrameworkExtras bundle for So maybe it would be best to initially have custom annotations and then use other bundles (Doctrine, SensioFrameworkExtras, etc.) as a fallback if necessary? As far as a naming convention, I would use There could be an argument for including the default annotations in Youshido/GraphQL and putting the fallbacks in this repo. |
Yep, I do have the same feeling... But without talking about this project, I think the annotation should be the PHP language feature, but not as in a comment. There's a lot of such annotations now |
@yarcowang that would kinda defeat the point, right? I still haven't gotten to the familiarity point of GraphQL to know if annotations alone can generate a full schema, but my feeling is that much of a schema could be generated this way. For instance, a GQL (GraphQL) field needs a type, which can be repurposed from the already existing Securing a field seems more tricky (unless I'm missing something). Assuming the currently authenticated user is the "viewer", then it would seem like finding a way to tap into I also don't have much experience with the annotation API, but the whole thing seems plausible. |
@bjunc Yep. But the annotation can do only one thing. If the name is |
Hey there! I'm currently working to add this feature to my project, the first issue im facing is that the only way I can find to access the entity repository is on the resolve method. I'm planning to add fields on the fly in the schema class, first thing is to get the entity annotations in the abstract field controller. |
I found a repo that extend this bundle: YoushidoGraphQLExtendedBundle. |
I ended up mothballing the idea of generating a schema from annotations, but if it were going to be done, I think it'd need to work similarly to how serialization/deserialization groups work. For instance, it seems to be a common design pattern to have distinct fields/types for different mutations, in addition to the root type. So for instance, lets say you had a |
@bjunc In my option, it will be a lot of work if you do follow GraphQL. Maybe extending REST is better. A great feature I want in GraphQL is the |
For me, I have yet to find a consequential downside to GraphQL. I've now built GQL backends in a few different technologies (currently building one in Phoenix/Elixir). The mutations are really interesting, as it's essentially the return to verb based actions. Takes a little getting used to since REST is so fundamentally noun based. However, I find it much easier to build out sophisticated endpoints in GQL. You can better protect certain fields that way too. All told though, I'm personally not pursuing the idea that the entity/model business layer both determines the database schema as well as the GQL schema. I know that's essentially what GraphCool has done with their service, so that might be something worth looking into for those who are interested in that. |
It seems like most of the necessary schema data is already present in Doctrine's Entity Annotations with perhaps some additional annotations for schema that cannot be inferred from the existing annotations. Is this something that can be done or am I missing something?
The text was updated successfully, but these errors were encountered: