mirumee/ariadne-graphql-modules

Combine ariadne-graphql-modules with the standard approach

pvanliefland opened this issue · 6 comments

I would like to try ariadne-graphql-modules but our codebase already uses the standard typedefs and bindables approach.

Would there be any way to build a schema that uses both typedefs/bindables and the new ObjectType, InputType, MutationType from ariadne-graphql-modules ?

This is not possible, but I understand that this is the way to go about it, so I'll look how this could be done.

I've recently moved moved large GraphQL API from bindables to modules and found that if you have tests that run queries against your schema, the process is relatively fast (took me maybe 6 hours). Here's how I've did it:

  • I've created new package called graphql2 next to graphql.
  • I've started creating types in graphql2. For each defined type I've simply copied schema and resolvers from graphql.
  • I've copied tests from verbatim from graphql to graphql2.
  • Once tests were passing, I've deleted graphql package and renamed graphql2 to graphql.

Here's final GraphQL API implementing two separate schemas (public and admin): Misago

@rafalp thanks for your reply.

I guess we could do a one-shot rewrite but with a large codebase and multiple developers working on GraphQL-related code at the same time, it could be somewhat messy.

If writing this "combine both approaches" code is not too complex, I could give it a try if you want - I'd just need some pointers.

Let me know if I can help.

I am thinking that make_executable_schema should have three extra kwargs:

  • extra_typedefs: Optional[Iterable[str]] = None
  • extra_bindables: Optional[Sequence[SchemaBindable]] = None
  • extra_directives: Optional[Sequence[Directive]] = None

Rest of task is updating validate_no_missing_definitions, build_schema and add_directives_to_schema logic to use those values.

If you are interested in trying it out, go for it.

I've got this working. I'll write a guide and release this as ariadne-graphql-modules v7 when its merged.

Wow, that's great @rafalp , looking forward to it. I had absolutely no time to try tackling this myself, sorry :/

Thank you for the update and all the work on ariadne

This is now available as version 0.7