Enable nested relationships in mutation inputs
@olirice ci sta già lavorando.
Dal 20/12/2022.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Describe the bug
It's not possible to insert an object along with its related object(s) in a single mutation. But that's exactly the beauty of GraphQL!
To Reproduce
Consider the following simple extract of a schema (Query, update, delete and all other types omitted for simplicity), where basically we have a One-To-Many relationship between Post and PostImage tables:
type Post {
id: UUID!
content: String!
createdAt: Datetime!
postImageCollection(
first: Int
last: Int
before: Cursor
after: Cursor
filter:PostImageFilter
orderBy: [PostImageOrderBy!]
): PostImageConnection
}
type PostImage {
id: UUID!
postId: UUID!
imageUrl: String!
createdAt: Datetime!
post: Post
}
type PostImageConnection {
edges: [PostImageEdge!]!
pageInfo: PageInfo!
}
type PostImageEdge {
cursor: String!
node: PostImage!
}
input PostInsertInput {
id: UUID
content: String!
createdAt: Datetime
}
type PostInsertResponse {
affectedCount: Int!
records: [Post!]!
}
input PostImageInsertInput {
id: UUID
imageUrl: String!
postId: UUID!
createdAt: Datetime
}
type PostImageInsertResponse {
affectedCount: Int!
records: [PostImage!]!
}
type Mutation {
insertIntoPostCollection(objects: [PostInsertInput!]!): PostInsertResponse
insertIntoPostImageCollection(objects: [PostImageInsertInput!]!): PostImageInsertResponse
}
Since I usually create a PostImage row every time I create a Post row, I need to execute two separate mutations to achieve this.
First:
mutation CreatePost {
insertIntoPostCollection(objects: {...}) {
affectedCount
records {
id
}
}
}
And after getting the result from CreatePost, I can execute:
mutation CreatePostImage {
insertIntoPostImageCollection(objects: {
imageUrl: "whatever",
postId: "" # here goes the Post id from previous mutation result
}) {
affectedCount
records {
id
}
}
}
Expected behavior
Expose nested objects in mutation inputs, so that I can directly create a Post along with a PostImage with just one mutation:
mutation CreatePost {
insertIntoPostCollection(objects: {
content: "blabla",
postImageCollection: {
objects: {
imageUrl: "whatever"
}
}
}) {
affectedCount
records {
id
content
postImageCollection(...) {
imageUrl
postId # this is automatically assigned by the mutation itself
}
}
}
See Hasura docs on this topic for reference.
Versions:
- PostgreSQL: any (this issue does not relate to Postgres itself)
- pg_graphql commit ref: b1cc167
- Lingua principale
- Rust
- Stelle
- 3.4k
- Fork
- 143
- Merge medio
- 4h 47m
- PR unite (30g)
- 2
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di supabase/pg_graphql
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
supabase/pg_graphql#646 ·
-
service_role treated as anon, by GraphiQLForse già presa @olirice l’ha presa 165 giorni fa. Apertatriage-required
supabase/pg_graphql#642 · 1 assegnatario ·
-
`graphql.resolve` crashes backend process on invalid `BigInt` filter value (`signal 6`, Postgres enters recovery)Forse di nuovo libera @olirice l’ha presa 167 giorni fa e non c’è nessuna pull request aperta. Apertatriage-required
supabase/pg_graphql#641 · 1 commento · 1 assegnatario ·
-
specifiedByURL field on __Type is declared in the schema but not handled by the resolverForse di nuovo libera @olirice l’ha presa 182 giorni fa e non c’è nessuna pull request aperta. Apertatriage-required
supabase/pg_graphql#629 · 1 assegnatario ·
-
Inconsistent handling of optional filter variables for `SETOF SQL` functions gives "Encountered Absent value" errorForse di nuovo libera @olirice l’ha presa 320 giorni fa e non c’è nessuna pull request aperta. Apertatriage-required
supabase/pg_graphql#617 · 1 commento · 1 assegnatario ·
Tutte le issue di supabase/pg_graphql
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Bump rustls-webpki, webpki-roots and webpki-root-certs for the emSign distrust (CVE-2026-111943)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 1 giorno
-
type: enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
franciscoBSalgueiro/en-croissant#1061 ·
I maintainer di solito rispondono entro 3 giorni
-
chore good first issue macros spire
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno