You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 }",
sourceArgs: # What args does this need to take? {
"input.id": "{root.authorId}"
}
)
}
It has missing commas and misplaced comments, but even after fixing those I cannot figure out how to make it work.
Hi @AlexeyRaga, I ran into a similar issue. This is just my best guess, but I believe the root cause is that (at least for the version of the library you/I are using), the @resolve() function is no longer supposed to be used under the additionalTypeDefs property in .meshrc.yaml file.
I believe what you're supposed to do now is use the additionalResolvers property in the file, to separate concerns from the additional type fields. This is what I have in mine, to give you an idea:
# .meshrc.yaml
...
additionalTypeDefs: |
...
extend type Book {
author: authors_v1_Author
}
additionalResolvers:
...
- targetTypeName: Book
targetFieldName: author
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
}
sourceArgs: # What args does this need to take?
input.id: "{root.authorId}"
The full source code is available here so you can look. I think the main point is just to move the logic from @resolve() under additionalResolvers.
the @resolve() function is no longer supposed to be used under the additionalTypeDefs property in .meshrc.yaml file.
This is not true, actually :)
@resolveTo directive is still the recommended way of extending the schema. The code in this example has recently been updated. Please let us know if the issue still persists.
The documentation for combining multiple sources has this code:
It has missing commas and misplaced comments, but even after fixing those I cannot figure out how to make it work.
I now have it as
And here is the error message that I get:
Using
additionalResolvers
in yaml works, but I still want to make it work in this more explicit way.I am using the following versions of packages:
Can anyone please advise on how to make it work?
The text was updated successfully, but these errors were encountered: