I am using Lighthouse with Laravel 5.8 to expose certain information.
Let's say I have 2 tables:
Order
--------
id
status
Results
--------
id
result_value
order_id
And my schema
type Order {
id: ID!
status: String,
results: [Result!]! @hasMany
}
type Result {
id: ID!
result_value: String,
order_id: Order! @belongsTo
}
type Query {
order(id: ID @eq): Order @find,
}
If I run the next query works as expected but...
{
order(id: 123) {
status
results {
result_value
}
}
}
What I'm trying to accomplish is return the order.results.result_value as null or empty when the order.status is equal to something.
I'm trying to use a custom field directive but I'm not sure if what I want it's achievable since the model isn't loaded yet
Ideally a custom directive would be ideal, since this is not the only attribute and not the only relation I need to hide.
I (think I) can't use @can as my requests are going to use custom authentication and the data is not available through a role-based access model.
@where, @whereConditions and other filter directives cannot be used, since I'm not trying to filter all the data. I want to hide a model attributes value when another model attribute equals to a certain value
Any suggestions on how I can approach this?