I need to send graphql an array of objects in the parameter but I am getting an internal error "Cannot convert object to primitive value". Im not sure if this is on my backend or in the query itself. I cant find an example online where there is an array of objects in the parameter. Here is the query:
{
searchProfile(query:"", limit: 10, sortBy: [{name: "name", sortOrder: "asc"}]){
items{
id
name
email
}
context
}
}
Im created a graphql wrapper for a rest api let me know if more information is needed like dataSource, or resolvers.
Schema:
searchProfile(
query: String
sortBy: [JSONObject]
cursor: String
limit: Int
context: JSONObject
): CustomerPagination
DataSource:
async searchProfile(query, sortBy, cursor, limit, context) {
return this.get('getProfile/search', {
...(query && { query }),
...(sortBy && { sortBy }),
...other data ommitted
});
}
Resolvers.js:
searchCustomer: async (_, { query, sortBy, cursor, limit, context }, { dataSources }) => {
return dataSources.api.searchProfile(query, sortBy, cursor, limit, context);
},
Everything works until I added the sortBy param in the gql query.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…