cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Order by relation type attribute, is it supported

Hi, I am trying to figure out if the Grandstack js library supports ordering by a relation attribute out of the box. For example given this schema here:

type Person 
{
	email:String!
	firstname: String!
	lastname: String!
	
	## Skills of a person, with expertiseLevel info
	skills(first: Int = 3, offset: Int = 0): [PersonSkill]			
}

type Skill 
{
	name1: String!
	name2: String
	
	## People who have this skill, with expertiseLevel info
	persons(first: Int = 3, offset: Int = 0): [PersonSkill]	
}

type PersonSkill @relation(name: "HAS_SKILL") 
{
    from: Person!
    to: Skill!
    expertiseLevel: Int!
}

I would like to be able to display folks who have a given skill, ordered by expertiseLevel descendent, something among these lines:

{
	Skill(name1:"Python")
	{
		name1,
		name2,
		persons(orderBy: expertiseLevel_desc)
		{
			Person
			{	
				firstname, 
				lastname
			}
			expertiseLevel,
		}
	}
}

I know this can be done out of the box with regular types but do not see the way of applying it to relation type

{
	Skill(orderBy: name1_asc)
	{
		name1,
		name2
	}
}
1 REPLY 1

MuddyBootsCode
Graph Steward

You should be able to do something similar to this by adding an enum type so for instance:

enum _FinanceOrdering{
   date_asc
   date_desc
}

works with:

type Fiance {
   date: Date
}

So if you were able to create the enum type you could then add orderBy: skill_asc, etc. to your queries.