-
Hello, I don't know how to pass the 'id' argument of my main query “getPartner(id: 110)” which won't have a partnerId or similar field in the response to the 'mdmid' argument of the extended field coverages. I haven't seen any examples of this in the documentation. additionalTypeDefs: `
extend type moralPerson {
coverages(from: String!, to: String!, system: String): getCoverages_response @httpOperation(...)
@join__field(graph: COVERAGES)
@resolveTo(
sourceName: "Coverages",
sourceTypeName: "Query",
sourceFieldName: "getCoverages",
sourceArgs: {
mdmId: "{root.id}", # => ❌ NOT WORKING
from: "{args.from}",
to: "{args.to}",
},
)
} |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
You need to add extend type Book {
author: authors_v1_Author @resolveTo(
sourceName: "Authors" # Which source does the target field belong to?
sourceTypeName: "Query", # Which root type does the target field belong to?
sourceFieldName: "authors_v1_AuthorsService_GetAuthor", # What is the source field name?
requiredSelectionSet: "{ authorId }", # What is the required selection on the target type to resolve the source field?
sourceArgs: { # What args the source field does need?
input: {
id: "{root.authorId}"
}
}
)
} |
Beta Was this translation helpful? Give feedback.
-
Tanks for your quick response, but in my case the 'id' is not in the response of the parent object, but in parameter of the query. I tried to add requiredSelectionSet but it dindn't work. Here is my full query : getPartner(id: "110") { // i want that "110" value in coverages mdmId argument
partnerType
... on moralPerson {
legalForm
radiationType
name
coverages(to: "2099-12-31", from: "2017-06-10") {
... on coverage {
mdmId
subscribedProducts {
billingFrequency
}
}
}
}
}
} |
Beta Was this translation helpful? Give feedback.
-
You might be able to do so by using programmatic additional resolvers. E.g. (non-working sample as I have removed parts of the logic) return {
selectionSet,
resolve(root, args, context: GatewayContext, info) {
let key = keyExtractor ? keyExtractor(root, typeUpper) : args.yourArg;
return batchedConnectionQuery({
root,
context,
info,
key,
argsFromKeys: function (ids: string[]) {
return { ...args, parentIds: ids };
},
// Function to extract the result from the batched response
valuesFromResults: (data) => {
return data;
},
});
},
};
} |
Beta Was this translation helpful? Give feedback.
It is not possible currently.
id
should be part ofmoralPerson
in order to make it work.