During the course of a GraphQL implementation I'm finding myself making a lot of circular references to keep the packages modular. Consider the following folder structure.
project/
__init__.py
graphql/
__init__.py
inputs/
__init__.py
company.py
contact.py
company.py
import graphene
import graphql.inputs.contact
class CompanyInput(graphene.InputObjectType):
contacts = graphene.List(graphql.inputs.contacts.ContactInput)
...
contact.py
import graphene
import graphql.inputs.company
class ContactInput(graphene.InputObjectType):
company = graphql.inputs.company.CompanyInput()
I consistently get the Django error:
ImportError at /api/v2/
Could not import 'gql.schema.schema' for Graphene setting 'SCHEMA'. AttributeError: 'module' object has no attribute 'company'.
Is this kind of circular referencing possible? Both contacts and companies need to be able to reference the input object class defined in the separate packages. This is so that graphql can take in inputs with with children and allow nested creation as well as allowing the input of an object with the creation of a parent.