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
Maybe I'm misunderstanding the docs, but @depend(on: ["id"]) would mean to me that the id field should be in the parent argument no matter what, but it isn't unless its asked for as well in the graphql query.
The text was updated successfully, but these errors were encountered:
That is working as intended, although it may not be well documented. If you have any columns you want to always select, you can specify them using the include argument on @model:
type SearchResult @model(table: "search_results", include: ["id", "type"])
Interesting, maybe it's the language in the docs, but I assumed that the following meant that if you say a field is dependent it will always be provided in the resolver when the field claiming the dependency is called. But it seems that if the dependency is also asked for in the query it is passed to the resolver of the dependent.
The @depend directive is used to indicate a field is not associated with a particular column, but still depends on one or more columns. If the field is requested, the specified columns will be included in the request and available to the field's resolver.
@tsiege Sorry, I think I misread your original post.
If field x includes @depend(on: "y"), then the resolver for x should be able to access the value for column y in its resolver through the first parameter passed to the resolver
return parent.y + '!';
}
If parent.y is undefined, that's a bug.
There is one caveat here that could be tripping you up. @depend expects column names, not field names, and what's exposed in the resolver will match the provided column names (even if they happen to have a field associated with them). This allows you to depend on columns that aren't explicitly part of your model. In other words, if you wrote @depend(on: ["foo_bar"]), you'll access it as parent.foo_bar.
Maybe I'm misunderstanding the docs, but
@depend(on: ["id"])
would mean to me that theid
field should be in the parent argument no matter what, but it isn't unless its asked for as well in the graphql query.The text was updated successfully, but these errors were encountered: