I have a new question.
So with the following Schema, I want to query for Profile
that belongs to a user, given that I would know the user’s ID on the UI.
type User {
id: String! @id @search(by: [hash])
userName: String! @search(by: [hash])
profile: Profile @hasInverse(field: user)
posts: [Post!] @hasInverse(field: user)
}
type Profile {
id: ID!
user: User!
coverPictureURL: String
avatarPictureURL: String
fullName: String @search
city: String @search
}
type Post {
id: ID!
user: User!
title: String! @search(by: [fulltext]) # TODO: remove title
description: String
createdAt: DateTime
updatedAt: DateTime
}
So, I wrote my query like this:
query QueryUserProfile ($userId: String) {
queryProfile {
user(filter: { id: { eq: $userId } }) {
id
}
id
fullName
avatarPictureURL
coverPictureURL
city
}
}
but this doesn’t work if I more than one users in the DB.
I get the following error:
{
"message": "Non-nullable field 'user' (type User!) was not present in result from Dgraph. GraphQL error propagation triggered.",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"queryProfile",
1,
"user"
]
}
What am I doing wrong ?
Should I need to query User instead? with the filter applied ?