Prisma1: Add inner connection fields

Created on 30 Jan 2018  路  8Comments  路  Source: prisma/prisma1

For this datamodel:

type Post {
  id: ID! @unique
  createdAt: DateTime!
  updatedAt: DateTime!
  isPublished: Boolean! # @default(value: false)
  title: String!
  text: String!
  author: User! @relation(name: "UserPosts")
}

type User {
  id: ID! @unique
  email: String! @unique
  password: String!
  name: String!
  posts: [Post!]! @relation(name: "UserPosts")
}

this is the generated User type:

image

It is lacking another field postsConnection: PostConnection!.

kinfeature areapi

Most helpful comment

Is there an ETA on when this will be implemented? This seems like a rather large missing feature.

All 8 comments

Is there an ETA on when this will be implemented? This seems like a rather large missing feature.

Thanks for your feedback, @vanimschootrein! I agree, this is a great feature to add. It's on our roadmap and we'll tackle it soon :slightly_smiling_face:

Any ETA on this bug? In a decent-sized schema, the workaround gets to be a bit much.

Update: I've spent hours today trying to make workarounds scale. The missing inner edge is just too hard to workaround in any generic way. I feel like my time might have been better spent fixing the actual deficiency in the Prisma code base :-( Can someone point me to the right part of the prisma code base?

FWIW, I'll mention two issues from a resolver perspective, to be specific.

  • For subscriptions, there isn't a clear opportunity to insert an edge from a resolver
  • For a schema that has lots of connections and queries that pull lots of nested objects, I am ending up doing crazy things to rewrite the return objects to nest them in {edge: {node}} to conform to the Relay specs.

How is anyone making Prisma work with Relay in the presence of these for a non-trivial, non-toy schema/app.

Is there any workaround on the client side to update the relay store?

Based on the schema above, I'm essentially adding a new post to the User. I need to update the store record and have react-relay re-render the components.

I would love to see this implemented!

Anything new here? I'd love to see this!

This is a bummer that Connections and Edges aren't fully supported for a Relay client. Seems like a critical omission. Is there any outline of what work needs to be done on this?

For reference if you're looking at writing your own spec for a resolver with a connection and a create mutation that returns an Edge:
https://github.com/este/este/blob/760d490a3ef4e7501c9381387a6dcb9ca6aa2646/server/resolvers/index.js#L106
https://stackoverflow.com/questions/38369825/what-restrictions-has-cursor-in-graphql-connections-for-relay

Was this page helpful?
0 / 5 - 0 ratings

Related issues

blocka picture blocka  路  74Comments

marktani picture marktani  路  35Comments

sapkra picture sapkra  路  40Comments

schickling picture schickling  路  44Comments

sorenbs picture sorenbs  路  52Comments