Open ralphchristianeclipse opened 6 years ago
https://www.apollographql.com/docs/apollo-server/features/unions-interfaces.html
this seems to not work at all on local state.
I have this snippet which resolves the correct type depending on the user.role
const roles = { employers: 'Employer', jobseekers: 'JobSeeker' }; User: { __resolveType: user => roles[user.role], name: ({ name = '' }) => name, role: ({ role = '' }) => role }, JobSeeker: { link: ({ id }) => ``, image: () => '' },
and do it like this on queries
query Auth { auth @client { id role ... on JobSeeker { link } ... on Employer { id } } }
which results to a __typename of User instead of Employer or JobSeeker
i can do this manually every query but it seems reusing it on the interface level would be easier
__resolveType is a graphql-tools feature, and is not currently supported with local resolvers. Marking as a feature request - thanks!
__resolveType
graphql-tools
https://www.apollographql.com/docs/apollo-server/features/unions-interfaces.html
this seems to not work at all on local state.
I have this snippet which resolves the correct type depending on the user.role
and do it like this on queries
which results to a __typename of User instead of Employer or JobSeeker
i can do this manually every query but it seems reusing it on the interface level would be easier