Robert_LY Robert_LY - 3 years ago 127
Python Question

Graphene-Django Filenaming Conventions

I'm rebuilding a former Django REST API project as a GraphQL one. I now have queries & mutations working properly.

Most of my learning came from looking at existing Graphene-Django & Graphene-Python code samples. There seem to be a lot of inconsistencies amongst them.

In some it was suggested that the GraphQL queries should be placed in
whereas the mutations should be placed in

What I'm thinking makes more sense is to instead have these two files hold their respective code:

I'm relatively new to Django & Python though so want to be sure that I'm not violating any conventions.

Interested in your thoughts!


Answer Source

There aren't any conventions yet, since GraphQL is a fairly new alternative method to REST. Thus, "conventions" are created at the moment we speak.

However, since schema is general-defined term you may rename it to queries.

This is my project structure:

       # holds the class Query. The GraphQL endpoints, if you like
        # holds the DjangoObjectType classes
       # holds the graphene.InputObjectType classes (for defining input to a query or mutation)
    # holds the mutations (what else?!)

So the (__init__) could be renamed to if you like. There is no much big difference between these two words.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download