Closed DZakh closed 1 year ago
I'm surprised the compiler allows multiple connections in one fragment. It's not something that'll be supported - move those out to separate fragments if you want the helpers to work (getConnectionNodes
and makeConnectionId
).
What's the point of having the connection directives both but no arguments for refetching? Or is this just a condensed example?
I've created a separate fragment, but the first connection name got prefixed with two underscores in the generated code inside of the makeNode
function
I've created a separate fragment, but the first connection name got prefixed with two underscores in the generated code inside of the
makeNode
function![]()
Interesting! Could you paste all relevant code?
My bad, that's the correct behavior 😅
What's the point of having the connection directives both but no arguments for refetching? Or is this just a condensed example?
There are multiple mutations with
@appendNode(
edgeTypeName: "WholesaleValuationRequest"
connections: $connections
)
that update different connections for different edge types on one fragment.
eg:
module Fragment = %relay(`
fragment ProspectDetailsPartnerOffers_prospect on Prospect {
wholesaleBids(first: 100)
@connection(key: "ProspectDetailsPartnerOffers_wholesaleBids") {
edges {
node {
...ProspectDetailsPartnerOffers_wholesaleBid
}
}
}
wholesaleValuationRequests(first: 100, where: { hasWholesaleBid: false })
@connection(
key: "ProspectDetailsPartnerOffers_wholesaleValuationRequests"
) {
edges {
node {
...ProspectDetailsPartnerOffers_wholesaleValuationRequest
}
}
}
}
`)
And
module Mutation = %relay(`
mutation AcceptValuationRequestMutation(
$id: ID!
$amount: Money!
$expiresAt: Time!
$connections: [ID!]!
) {
acceptValuationRequest(
id: $id
input: { amount: $amount, expiresAt: $expiresAt }
) {
wholesaleBid
@appendNode(edgeTypeName: "WholesaleBid", connections: $connections) {
...ProspectDetailsPartnerOffers_wholesaleBid
...ProspectDetailsCreateBidModal_wholesaleBid
}
id @deleteRecord
}
}
`)
module Mutation = %relay(`
mutation SendValuationRequestMutation(
$prospectID: ID!
$emailContent: String!
$wholesalePartnerIDs: [ID!]!
$connections: [ID!]!
) {
generateValuationRequest(
input: {
prospectID: $prospectID
emailContent: $emailContent
wholesalePartnerIDs: $wholesalePartnerIDs
}
)
@appendNode(
edgeTypeName: "WholesaleValuationRequest"
connections: $connections
) {
...ProspectDetailsPartnerOffers_wholesaleValuationRequest
}
}
`)
Instead of passing __id
I get connections like:
ProspectDetailsPartnerOffers_prospect_graphql.makeConnectionId(
prospectID->RescriptRelay.makeDataId,
)
Right! That looks good. And it's working as intended now breaking things out to two fragments?
The
makeConnectionId
works with only one connection and ignores the other ones.Here's the fragment example:
The generated code looks like this: