grapher
grapher copied to clipboard
Graphql, astToQuery and subarrays
Here is my typeDefs and resolvers
type Query {
professionals(companyId: String!): [Professional]
company(route: String!): Company
}
type Company {
name: String!
route: String
professionals: [Professional]
}
type Professional {
name: String!
avatar: String
company: Company
services: [Service]
}
type Service {
_id: String
name: String
price: String
duration: Int
categoryId: String!
}
company(_, args, { db }, ast) {
return db.companies.astToQuery(ast, {
$filters: {
route: args.route
}
}).fetchOne()
},
professionals(_, args, { db }, ast) {
return db.professionals.astToQuery(ast, {
$filters: {
companyId: args.companyId
}
}).fetch();
},
The problem is when querying companies
, the services
have the following result
{
name: [..],
price: [..]
}
Here is my query. Queries professionals
works normally
query {
company(route: "_") {
name,
professionals {
name,
services {
_id,
name,
price
}
}
}
}
How did you link company and professionals inside grapher ?