Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-10-2019 07:38 AM
Hi,
I'm trying to query relationship properties via GraphQL.
As was mentioned here:
https://grandstack.io/docs/graphql-relationship-types.html#relationships-with-properties ,
I built a relationship type to include in my query.
The underlying graph is quite simple: There are skill profiles (of users) that are defined by their relationships to single (atomic) skills. This relationship has a 'value' (or 'key figure') that describes how proficient someone is in a that skill.
The relevant parts of the schema look like this:
type Skillprofile {
_id: Long!
name: String!
has_skill: [Skill] @relation(name: "HAS_SKILL", direction: "OUT")
skillfeature: [Skillfeature]
persons: [Person] @relation(name: "HAS_SKILLS_REPORTED_IN", direction: "IN")
}
type Skillfeature @relation(name: "HAS_SKILL") {
from: Skillprofile
to: Skill
value: Float
}
However, when I ask for the relationship in GraphQL, I get an error:
"code": "GRAPHQL_VALIDATION_FAILED",
"exception": {
"stacktrace": [
"GraphQLError: Cannot query field \"from\" on type \"_SkillprofileSkillfeature\".",
I'd expect that I can simply query the 'from' and 'to' fields of the relationship type, just like that 'value'. Which, BTW, is returned properly.
Thanks for any input,
best regards,
Christoph
07-13-2019 01:47 PM
Try
type Skill {
id: ID!
name: String!
persons: [Person] @relation(name: "HAS_SKILL", direction: "IN")
}
type Person {
id: ID!
name: String!
skills: [Skill] @relation(name: "HAS_SKILL", direction: "OUT")
}
07-13-2019 02:36 PM
or try
type Skill {
id: ID!
name: String!
persons: [Has_Skill]
}
type Person {
id: ID!
name: String!
skills: [Has_Skill]
}
type Has_Skill @relation(name: "HAS_SKILL") {
from: Person
to: Skill
level: Float
}
look for in schema
mutation {
AddSkillPersons
}
07-14-2019 03:03 PM
Thank you, I'll give it a try!
best,
Christoph
01-24-2020 09:58 AM
Did anybody managed to read properties on a relationship using graphQL?
none of the above solution worked for me.
What I am trying is just to access a property like type
from below
(User)-[:HAS_SKILL
{type:"technical"}]->(Java)
02-13-2020 03:46 AM
any solutions here?
I wondering about this problem, too.
03-27-2020 11:51 AM
Based on @futuristnicole 's second solution as the GraphQL schema, the client side code should be able to query that with the following GraphQL query:
query {
Person {
name
skills {
level
Skill {
name
}
}
}
}
Only other issue for your query, @dejavu1987, is I don't think you can use 'type' for a property of a relationship. It will just be ignored.
12-03-2021 08:17 AM
Funny, doing a web search, I came back to my own question. 🙂 I'll give the solution of iuviene a try.
07-20-2020 09:13 AM
In this example, is there a clean way to sort by skills level?
All the sessions of the conference are now available online