Match multiple labels in an OR but assign each label their own variable

Hello, I'm trying to do something like this:

MATCH(a:Actor)-[]->(d:Director|p:Producer|w:Writer)

However, I get the error:
Mixing label expression symbols ('|', '&', '!', and '%') with colon (':') is not allowed.

I understand that I need to use a single variable for Director, Producer, and Writer nodes, but I am wondering if it is possible to assign them their own variable in an expression like this. I would prefer not to use OPTIONAL MATCH.

Thank you

You are correct in identifying where your syntax error is. There are different ways to handle this. I would like to know how you are going to process the results in order to recommend the best. Until then, I will show you two approaches.

I do not like 'optional match' here if you string them together back-to-back, as you will get a Cartesian product of the results. You could process each Node type in separate call subqueries as well.

MATCH(a:Actor)-->(d:Director|Producer|Writer)
WITH a, collect(d) as others
WITH a, 
    [i in others where i:Director] as directors,
    [i in others where i:Producer] as producers,
    [i in others where i:Writer] as writers
//do something with the collections per Actor

Or, using collect subqueries:

MATCH(a:Actor)
WITH a, 
    collect{match(a)-->(d:Director) return d} as directors,
    collect{match(a)-->(d:Producer) return d}  as producers,
    collect{match(a)-->(d:Writer) return d} as writers
//do something with the collections per Actor

the subquery solution would have a benefit when the queries in each collect subquery are different; thereby, providing more flexibility. In your case, all the queries are the same, so first solution using one match and multiple list comprehension operations to separate the items is probably more efficient.

I can provide more details if you provide what you are going to do with the information.