[relay] Two many-to-one connection fails


#1

Hi,

on graph.cool I have those models:

type GroupSubscriberStatus @model {
  group: Group! @relation(name: "GroupSubscriberStatusOnGroup")
  id: ID! @isUnique
  subscriber: Subscriber! @relation(name: "GroupSubscriberStatusOnSubscriber")
  status: Status!
}

type Subscriber @model {
  email: String! @isUnique @defaultValue(value: "")
  id: ID! @isUnique
  groupSubscriberStatuses: [GroupSubscriberStatus!]! @relation(name: "GroupSubscriberStatusOnSubscriber")
}

type Group @model {
  account: Account! @relation(name: "GroupOnAccount")
  createdAt: DateTime!
  id: ID! @isUnique
  title: String!
  updatedAt: DateTime!
  groupSubscriberStatuses: [GroupSubscriberStatus!]! @relation(name: "GroupSubscriberStatusOnGroup")
}

When I create model GroupSubscriberStatus only with one many-to-one connection, then it works. But complete example as above throws via relay modern:

ERROR:
Error writing modules:
RangeError: Maximum call stack size exceeded

Thanks for any ideas.


#2

Here is complete schema without the GroupSubscriberStatus model:

# projectId: cj9prtat25tj90151299b2m4i
# version: 11

type File @model {
  contentType: String!
  createdAt: DateTime!
  id: ID! @isUnique
  name: String!
  secret: String! @isUnique
  size: Int!
  updatedAt: DateTime!
  url: String! @isUnique
}

type User @model {
  createdAt: DateTime!
  id: ID! @isUnique
  updatedAt: DateTime!
  posts: [Post!]! @relation(name: "PostAuthor")
  accounts: [Account!]! @relation(name: "AccountOnUser")
  webs: [Web!]! @relation(name: "WebOwner")
  email: String @isUnique
  password: String
}

type Post @model {
  createdAt: DateTime!
  id: ID! @isUnique
  text: String!
  updatedAt: DateTime!
  author: User! @relation(name: "PostAuthor")
}

type Account @model {
  createdAt: DateTime!
  groups: [Group!]! @relation(name: "GroupOnAccount")
  id: ID! @isUnique
  title: String!
  updatedAt: DateTime!
  users: [User!]! @relation(name: "AccountOnUser")
}

type Group @model {
  account: Account! @relation(name: "GroupOnAccount")
  createdAt: DateTime!
  id: ID! @isUnique
  title: String!
  updatedAt: DateTime!
}

type Subscriber @model {
  email: String! @isUnique @defaultValue(value: "")
  id: ID! @isUnique
}

type Web @model {
  id: ID! @isUnique
  name: String!
  domain: String!
  owner: User! @relation(name: "WebOwner")
  createdAt: DateTime!
  updatedAt: DateTime!
}

#4

You are encountering a bug in the Relay compiler with recursive input types.
Here’s a PR for a fix: https://github.com/facebook/relay/pull/2142


#5

Exactly. There is also fix. :slight_smile: