pythondjangographene-pythonstrawberry-graphql

In a new project, Graphene or Strawberry? Why?


which lib is better to integrate with a new django project?

i red the docs and still doesnt know how performatic or easier to integrate each one can be in prod environment.

i used graphene before to integrate with some pipefy code that i did at work but im pretty new in graphql and dont know at this point what way i should go.


Solution

  • I'm the maintainer of Strawberry, so there might be some bias in my answer 😊

    Both Strawberry and Graphene are based on GraphQL-core which is the library that provides the GraphQL execution, so in terms of performance they are comparable. For Strawberry we have a performance dashboard here: https://speed.strawberry.rocks/ and you can see we've been working to make it as fast as we can, but GraphQL-core will always be the deciding factor for the speed[1]

    For Django, I personally don't tend to use the integrations from models as I think it is a bad practise, but both Graphene and Strawberry have integration in that sense. Graphene integration's probably more mature, but Strawberry's is getting better every day (the maintainer works on both strawberry-django and strawberry-django-plus, and he's doing amazing work).

    Graphene has also probably more extensions at the moment and maybe more guides online, though most might not be up-to-date any more.

    Strawberry is well maintained and makes releases quite often, and we are trying to not have big breaking changes, even if we are at version 0.x. Graphene has been unmaintained for a bit but luckily now there are more maintainers.

    I'd definitely encourage you to do a small prototype with both libraries and see which one resonates the most with you as they have different DX, with Strawberry leveraging Python Type Hints and Graphene having a syntax very similar to Django models.

    [1] I do have some ideas on how we can make the library faster, but I don't know when I'll be able to implement them :)