Here I displayed titles of articles having the community id 996.
What I would like to do is to be able, in the user interface, to display bloc like the image, and each blocs will be each community (for example the first bloc will be the community 996)
I would like to use a precise Cypher request in order to display articles by clusters (community in the request) in the user interface.
MATCH (a:ARTICLE)
WITH a, collect(a.community) as community
ORDER BY a.community
RETURN community, count(a), a.title
The graphql schema has all the types required.
I pasted this request in the schema.graphql.
type Query {
communities: Int! @cypher(statement:"
MATCH (a:ARTICLE)
WITH a, collect(a.community) as community
RETURN community, count(a), a.title")
}
I don't know if it is the good way to do it. If it is what do I have to do next ?
And if not where do I have to put this request in the GRANDstack starter ?
You defined your query as returning an int, but your cypher returns 3 fields so i don't think that's gonna work how you'd expect. as i was writing the next part of this answer i realized your intent could be one of several and i didn't want to guess. for the example you have; i'd change it to
type Query {
communityCount: Int! @cypher(statement:"
MATCH (a:ARTICLE)
WITH a, collect(a.community) as community
RETURN size(community)")
}
type community{
title:string
count:Int
}
type query{
communityCount: [community] @cypher(statement:"
MATCH (a:ARTICLE)
WITH a, collect(a.community) as community
RETURN {title:a.title, count:size(community)}" )
}
Here I displayed titles of articles having the community id 996.
What I would like to do is to be able, in the user interface, to display bloc like the image, and each blocs will be each community (for example the first bloc will be the community 996)
when you say "it didn't work" can you elaborate ?
to limit by community you might consider adding a parameter to the query. something like this
type query{
communityCount(communityNumber:ID!): [community] @cypher(statement:"
MATCH (a:ARTICLE)
WHERE a.community = $communityNumber
WITH a, collect(a.community) as community
RETURN {title:a.title, count:size(community)}" )
}