Solved

Unable to mark the objects in the list as non nullable.

  • 22 March 2023
  • 2 replies
  • 50 views

  1. One or more employees must belong to a department and each employee instance is non nullable. Below type is accepted through UI in CDF.

type Department {

name: String!,

employees: [Employee!]!

}

2. Zero or more employees can belong to a department and it can be a null object or an employee instance. Below type is accepted through UI in CDF.

type Department {

name: String!,

employees: [Employee]

}

3. Zero or more employees can belong to a department and it has to be a non null employee instance. Below type isn't accepted through UI in CDF.

type Department {

name: String!,

employees: [Employee!]

}


I am trying to enforce field nullability use case as suggested here - https://www.apollographql.com/docs/apollo-server/schema/schema/#field-nullability

Below example may make my above question more meaningful in the CDF FDM context.

type Department {

name: String!,

employees: [String!]

}

  • How can I ensure that the list of strings are non-nulls?

  • Also, Would Strings be stored in a separate node and connected through edges or would the list of Strings be stored in the same node instance?

icon

Best answer by Anita Hæhre 13 April 2023, 13:45

View original

2 replies

Userlevel 3

Hi, for relations to other types, we don’t support the requiredness. You will not be able to have this strict requirement due to the coupling of nodes this would require. 

For strings, what you can do is

type Department {

name: String!,

someStrings: [String!]!

}

which achieves what you want. The someStrings property is then never null, but can be an empty list. String lists are stored on the same node instance.

Userlevel 6
Badge

Hi @Shreyas Mehta I hope @Anders Hafreager reply above gave you what you were looking for. I’ll go ahead and close this thread for now, feel free to open it again should you have further questions. 

Reply