-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mocking: Resolving a union throws an error #2382
Comments
@ardatan thoughts? |
I am getting a similar issue attempting to replace an openapi handler field that is generated as JSON with an Interface. Generated Source Type OrganizationsOrganizationProfiles {
data: [JSON]
} Replace-Field Transform - replace-field:
typeDefs: ./src/organizationsTypeDefs.graphql
replacements:
- from:
type: OrganizationsOrganizationProfiles
field: data
to:
type: OrganizationProfilesResponse
field: data organizationsTypeDefs type OrganizationProfilesResponse {
data: [OrganizationProfile]
}
interface OrganizationProfile {
id: String
organizationId: String
type: String
}
type LocationProfile implements OrganizationProfile {
id: String
organizationId: String
type: String
status: Status2
address_line_1: String
address_line_2: String
city: String
state: String
postal_code: String
country: String
timezone: String
latitude: Int
longitude: Int
}
type VideoContentProfile implements OrganizationProfile {
id: String
organizationId: String
type: String
status: Status2
maxContent: Int
scope: String
} The typing works correctly but when it's resolved throws the same error.
I have tried adding the Attempted Additional Resolver import { Resolvers } from '@mesh/index';
export const resolvers: Resolvers = {
OrganizationProfile: {
__resolveType: (obj, context, info) => {
if (obj.type === 'organizations.organization_profiles.VideoContentProfile') {
return 'VideoContentProfile'
}
if (obj.type === 'organizations.organization_profiles.LocationProfile') {
return 'LocationProfile'
}
return null
}
},
}; |
Hello folks! So it appears I got an issue somehow similar. All my types are well generated, but when trying to resolve the mutation I get the same error as you guys mentioned. In my configuration I have an additional resolver added, so I tried to see if I added a custom So I was wondering if someone found a solution, or if you know a way to override the Thank you! 🙏 |
I have to say, I am pretty disappointed in how these tickets get addressed, let alone resolved. |
Would you give a try to create a failing test in a PR or maybe get some progress towards fixing it |
@nemonemi did you ever find a solution to this? |
Hi @james-butter, unfortunately, I have to say that I've decided to stop using graphql-mash. I was very excited about it, and after lots of issues, and not-so-responsive support, I gave up. |
Damn, that's a shame. There does seem to be so much magic going on behind the scenes and I'm really unsure on how to get the union resolver going here. Hope you went onto a framework that you love! |
Describe the bug
Without the union return type, everything works, but when having a union as a return type it throws an error.
To Reproduce
Steps to reproduce the behavior:
yarn start
uploadFile
mutation. -> it worksuploadFileWithUnion
mutation. -> throws an errorThis is the resolver:
Expected behavior
It should work.
Question
It suggest using the
resolveType
orisTypeOf
. How can one provide those methods from within the graphql-mesh resolvers?The text was updated successfully, but these errors were encountered: