-
Notifications
You must be signed in to change notification settings - Fork 12
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
TypeError on returnType
when returning Union from mutations
#53
Comments
Hey, this resolver seems good to me. There is no "GraphQL" way to resolve anything and Mirage GraphQL doesn't have any opinions about how you should resolve things either. I would, however, highly encourage usage of Mirage's API above all else, as you have already done here 👍 const resolvers = {
updateMembershipInstance: (parent, args, context, info) => {
const { mirageServer } = context
const { id: membershipInstanceId } = args.input
const membershipInstance = mirageServer.schema.membershipInstance.find(membershipInstanceId)
if (membershipInstance) {
membershipInstance.update(args.input)
}
const response = new UpdateMembershipInstanceSuccess()
response.membershipInstance = membershipInstance
return response
}
}
export class UpdateMembershipInstanceSuccess {
get __typename () {
return 'UpdateMembershipInstanceSuccess'
}
} As for this approach... updateMembershipInstance: (parent, args, context, info) => {
const membershipInstance = mirageGraphQLFieldResolver(...arguments)
const response = new UpdateMembershipInstanceSuccess()
response.membershipInstance = membershipInstance
return response
} ...you are using |
@jneurock thank you so much for your time ❤️ , and understood, what I find a bit confusing is that |
Could have something to do with this: updateMembershipInstance: {
__typename: 'UpdateMembershipInstanceResponse',
__resolveType: (obj, context, info) => {
debugger
},
resolveType: (obj, context, info) => {
debugger
},
__returnType: () => {
debugger
},
returnType: () => {
debugger
}
}, I wonder if it's somehow altering what gets passed as the export default function mirageGraphQLFieldResolver(obj, args, context, info) {
let { isList, type } = unwrapType(info.returnType);
// ...
} |
This is related to a comment made on #52 that was out of context for the issue where it was added to.
We've defined a mutation to work with basic updates on our
MembershipInstance
model, we defined this schemaand we have this mutation handler on our resolvers we're passing to
createGraphQLHandler(...)
this code, as is, works, but we're wondering if this is the graphql way to do things, specially because we're calling mirage directly to update records, then we're also building a typed response to avoid graphql union errors. What we're discussing with the rest of the team is if this shouldn't have a different handler, deferring the actual data update work to mirage/graphql, we tried this also
but this approach fails, with this error
which makes me thing we're not using
mirageGraphQLFieldResolver
correctly, but what I find specially confusing is that we also addedreturnType
to our types resolvers, but it seems we're not even hitting those, and we cannot still find which type from our schema this error is originating fromany help or comment would be super welcomed!
The text was updated successfully, but these errors were encountered: