Skip to content

[relay-compiler] Compiler doesn't work for connections when types are non-nullable #1835

Description

@nikolasburk

I'm having an issue with the relay-compiler that fails when fields are required.

Here's a simplified version of the schema that I used when I was hitting the issue.

allPosts(after: String, before: String, first: Int, last: Int): PostConnection!

type PostConnection {
  pageInfo: PageInfo!
  edges: [PostEdge]
}

type PostEdge {
  node: Post!
  cursor: String!
}

type PageInfo {
  hasNextPage: Boolean!
  hasPreviousPage: Boolean!
  startCursor: String
  endCursor: String
}

type Post {
  id: ID!
  title: String!
}

Using required fields on the connections caused the compiler to fail with the following error:

Invariant Violation: RelaySchemaUtils: Expected type `PostConnection!` to be an object or interface type.

image

Using the following schema without required fields works:

allPosts(after: String, before: String, first: Int, last: Int): PostConnection

type PostConnection {
  pageInfo: PageInfo
  edges: [PostEdge]
}

type PostEdge {
  node: Post
  cursor: String
}

type PageInfo {
  hasNextPage: Boolean
  hasPreviousPage: Boolean
  startCursor: String
  endCursor: String
}

type Post {
  id: ID!
  title: String!
}

Feel free to take a look at the full project (note that the README doesn't yet include instructions about setting up the relay-compiler).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions