strawberry-graphql / strawberry

A GraphQL library for Python that leverages type annotations 🍓
https://strawberry.rocks
MIT License
3.96k stars 528 forks source link

Improve schema codegen #3097

Open patrick91 opened 1 year ago

patrick91 commented 1 year ago

Follow up from https://github.com/strawberry-graphql/strawberry/pull/3096

### Tasks
- [ ] Add support for federation directives
- [ ] Add support for custom schema directives
- [ ] Add support for Generic types when detecting relay connections (worth doing it I think :))

Upvote & Fund

Fund with Polar

Voldemat commented 1 year ago

Please consider giving custom schema directives higher priority, this is the exact feature I need. I thinking about defining validation rules using it, so they would be synchronized between frontend and backend codebases. Is there any workaround I can use for now? And when do you plan to ship official support?

patrick91 commented 1 year ago

@Voldemat can you show me an example of this? what's the sdl and how would you like the schema to become?

Voldemat commented 1 year ago

The first problem is right now schema_directives is not exposed to introspection api, we use graphql-inspector to enforce compatibility between out file schema types and backend api types. After introspecting api, I didnt find any references of directive, opposed to introspection of file types using the same graphql-inspector. Im not fully aware on which side the problem may be, so that is why I`m explaining whole process.

I created Keys directive as it is explained in the docs and even add it to schema_directive list to Schema initializer, however Keys directive is still absent from introspection api.

patrick91 commented 1 year ago

@Voldemat at the moment the GraphQL introspection doesn't support schema directives, but strawberry does when exporting the schema.

Just to clarify, this issue is about converting SDL to python, not python to SDL 😊 if you have issues with exporting the schema with directives feel free to open a new issue, I'll be happy to help!

Voldemat commented 1 year ago

Ok, thanks for clarification.