Comments (4)
I'm closing this as stale / out of scope, as it's really more a question about Relay's JS side (and questions like this are probably better addressed in Slack).
from absinthe_relay.
In your example, couldn't you do:
cursor = Connection.offset_to_cursor(length(faction.ships) - 1)
Assuming the new resource is the last one in the collection. Otherwise:
cursor = faction.ships
|> Enum.find_index(fn(x) -> x == ship end)
|> Connection.offset_to_cursor
from absinthe_relay.
Maybe yes @panayi ... at the moment I was writing the example I believe I didn't know about the function Connection.offset_to_cursor
.
Anyway, the idea, based on the Javascript implementation is to return the cursor for the recently added object and thus, I believe your latter suggestion seems more appropriate in case someone else is adding ships to a faction.
from absinthe_relay.
Hello again.
I have some more questions regarding RANGE_ADD
mutation. Suppose I have the following mutation in Relay
import Relay from 'react-relay';
export default class AddMemberMutation extends Relay.Mutation {
getMutation() {
return Relay.QL`mutation {addMember}`;
}
getVariables() {
const { member } = this.props;
return {
...member
};
}
getFatQuery() {
return Relay.QL`
fragment on AddMemberPayload {
club { members },
newMemberEdge,
errors
}`;
}
getConfigs() {
return [{
type: 'RANGE_ADD',
parentName: 'club',
parentID: this.props.club.id,
connectionName: 'members',
edgeName: 'newMemberEdge',
rangeBehaviors: {
'': 'append'
'status(active)': 'prepend'
}
}];
}
}
I'm trying to understand the following:
a. How do we know the page info to be used to return the Club's membersConnection in the mutation?. For example, Connection.from_query
needs some page info like first: 10
to know what "page" to return.
b. Supposing I figured out what connection to return, how can determine the cursor of the newMemberEdge
without having to cycle through the edges to find the corresponding member?
from absinthe_relay.
Related Issues (20)
- Absinthe.Relay.Connection.Options HOT 3
- Custom Cursor from external endpoint
- Absinthe.Relay.Node.ParseIDs causes runtime error if occurs more than once in a mutation query
- Helpers for working with connections
- Breaking change in 1.5: Absinthe.Relay.Mutation.Notation.Modern.output/2
- Integration with Dataloader HOT 6
- Warning about ecto dependency after upgrading Elixir to 1.11 HOT 1
- Node object from interface implementation results in duplicate ID HOT 2
- ParseIDs middleware cannot find schema_node on subsequent `input` field
- Release new version HOT 2
- Feature request: use of non-binary id HOT 4
- Converting internal ecto foreign key ids to global ids HOT 1
- config Absinthe.Relay causes warnings HOT 2
- Why using offset-based pagination in Connection.from_query? HOT 1
- Include complexity support in connection notation HOT 13
- New release HOT 3
- changelog HOT 1
- Absinthe.Resolution.project/1 for child fields HOT 3
- Issues while upgrading from absinthe_relay from 1.4 to 1.5 HOT 1
- PageInfo needs to be shareable in GraphQL Federation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from absinthe_relay.