This is an issue we have ran into multiple times now... very much looking forward to others' opinions!
Scenario Description (for illustration purposes):
Somebody visits our website, perhaps they fill out some forms, whatever. To us, this person is a prospect/lead. They have not been fully onboarded as a customer; they are simply a potential future customer.
Certain actions can be performed on these Prospects
, such as adding certain data to their profile. Let's call this add_foobar_data
. Of course, if they become a real customer (somebody consuming our service), we still need to be able to add/remove said data from their account.
Scenario (tl;dr):
Prospects
can becomeCustomers
- Mutation
add_foobar_data
conceptually applies to bothProspects
andCustomers
Prospects
only have a subset of data ofCustomers
(they are a true subset; currentlyCustomers
have a lot of non-nullable fieldsProspects
do not have)
Options:
Create a union type, e.g.
Customerable
.add_foobar_data
would return aCustomerable
(or backref to aCustomerable
) rather than a specific type.Create separate mutations for modifying
Prospects
andCustomers
(add_foobar_data_to_prospect
,add_foobar_data_to_customer
)Everybody is a
Customer
! Make all those non-nullable fields onCustomer
that are not inProspect
nullable and add a new flag calledisProspect
(orisDraft
if we want to change how we think about the flow).Perhaps some other approach I did not think of...
Anybody have thoughts on what is the best approach to this situation and why?