Last active
December 24, 2017 08:53
-
-
Save dobleuber/c74625704c37d7245b747d31b3c433cc to your computer and use it in GitHub Desktop.
Relay problem UI is no updated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mutation = graphql` | |
mutation UpdateUserObjectSelectionMutation($input: UpdateUserObjectSelectionInput!) { | |
updateUserObjectSelection(input: $input) { | |
UserObjectSelection { | |
id | |
} | |
SelectItem { | |
id | |
} | |
} | |
} | |
`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Object = ({ object, selection, onSelectItem }) => { | |
const {id} = object; | |
return ( | |
<div> | |
<span>{id}</span> | |
<div className="item-list"> | |
object.selectionType.items.edges.map(({ node }) => ( | |
<Item | |
key={node.__id} | |
item={node} | |
userObjectSelectionId={selection.id} | |
onSelectCard={onSelectItem} | |
selectedItem={selection.item} | |
/> | |
)) | |
</div> | |
</div>); | |
}; | |
createFragmentContainer(Object, graphql` | |
fragment Object_story on Object { | |
details | |
selectionType { | |
id | |
items: { | |
edges: { | |
node { | |
...Item_item | |
} | |
} | |
} | |
} | |
} | |
fragment Object_selection on UserObjectSelection { | |
id | |
selectedItem: item { | |
...Item_selectedCard | |
} | |
} | |
`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const query = graphql` | |
query ObjectPageQuery($objectId: ID!, $userObjectSelectionId: ID!) { | |
object: node(id: $objectId) { | |
...Object_object | |
} | |
selection: node(id: $userObjectSelectionId) { | |
...Object_selection | |
} | |
} | |
`; | |
changeSelectedItem (selectionId, itemId) { | |
mutateSelectedItem(selectionId, itemId, () => console.log('updated')); | |
} | |
/// | |
render={({ error, props }) => { | |
if (error) { | |
return <div>{error.message}</div>; | |
} else if (props) { | |
return ( | |
<div className="object-page"> | |
<Item | |
object={props.object} | |
selection={props.selection} | |
onSelectItem={this.changeSelectedItem} | |
/> | |
</div> | |
); | |
} | |
return <div>Loading</div>; | |
}} | |
/// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User @model { | |
id | |
userObjectSelection: [UserObjectSelection!]! | |
} | |
type Object @model { | |
id | |
name | |
userObjectSelection: [UserObjectSelection!]! | |
selectionType: SelectionType! | |
} | |
type SelectionType @model { | |
id | |
items: [SelectItem!]! | |
objects: [Object!]! | |
} | |
type SelectItem @model { | |
id | |
name | |
selectionType: SelectionType! | |
userObjectSelection: [UserObjectSelection!]! | |
} | |
type UserObjectSelection @model { | |
id | |
user: User! | |
object: Object! | |
selectedItem: selectItem | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment