How to create array field of the whole model in the schema


Hi I’m a newbie in graphcool, can I ask on how to create an array field of the whole model. I need to create types similar to this: (notice e.g. emails: Array)

export interface EmailProps {
    label?: string;
    email?: string;

export interface PhoneProps {
    label?: string;
    phone?: string;

export interface AddressProps {
    label?: string;
    address?: string;

export interface PartyProps {
    name?: string;
    emails?: Array<EmailProps>;
    phones?: Array<PhoneProps>;
    addresses?: Array<AddressProps>;

and I’m using it like this (using props PartyProps)

emailsList = ((em, idx) => {
                return (
                        key={'A' + idx.toString()}

Data modelling: related types/tables vs nested json

Hi, I wasn’t sure whether the emails, names and phones have any relation, so I also made an example which refers to people rather than only emails, phones and names. Hope it helps :smile:!

type Party @model {
  id: ID! @isUnique

  names: [String!]!
  emails: [String!]!
  phones: [String!]!

# or

type Party @model {
  id: ID! @isUnique

  people: [User!]! @relation(name: "UsersParties")

type User @model {
  id: ID! @isUnique

  name: String!
  email: String!
  phone: String!

  parties: [Party!]! @relation(name: "UsersParties")


Thanks for the response @matic, but the structure should really have an array of emails, array of phones and array of addresses. I’m not sure on how to do it in graphQL, any idea on how to do it?



If [String] does not suffice, you can either use [Json] so you can store an Array of Json objects, or create ‘full’ model Types with relations.