Querying relationship properties in GraphQL

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

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")
}

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
}

Thank you, I'll give it a try!

best,
Christoph

1 Like