[Answered ]-How do I reference multiple schema files in Graphene Django project settings for access in graphql?

1👍

The solution is to make a third schema.py file in the same folder as your settings.py file. The new schema.py file should look like:

import graphene

import first_app.schema as first_app
import second_app.schema as second_app

class Query(first_app.schema.Query, second_app.schema.Query, graphene.ObjectType):
    # Inherits all classes and methods from app-specific queries, so no need
    # to include additional code here.
    pass

class Mutation(first_app.schema.Mutation, second_app.schema.Mutation, graphene.ObjectType):
    # Inherits all classes and methods from app-specific mutations, so no need
    # to include additional code here.
    pass

schema = graphene.Schema(query=Query, mutation=Mutation)

Your settings.py file should then reference the new third schema.py file:

GRAPHENE = {
    'SCHEMA': 'parent_folder.schema.schema'
}

Leave a comment