Sorting data from a GraphQL+GraphCool Endpoint

type Entry implements Node {
baby: Baby @relation(name: "BabyOnEntry")
childType: String!
createdAt: DateTime!
id: ID! @isUnique
parentType: String!
time: DateTime! @defaultValue(value: "2017-07-30T22:51:45.384")
updatedAt: DateTime!
}
query {
user {
id
baby {
id
entires {
id
parentType
childType
time
}
}
}
}
import React from "react";
import { gql, graphql } from "react-apollo";
const EntriesList = props => { if (props.data.loading) {
return (
<p>{props.data.error.message}</p>
);
}

const entries = props.data.user.baby.entries;
return (
<ul>
{entries.map((entry, key) =>
<li>{entry.time}</li>
}
</ul>
);
}
export const entriesListQuery = gql`
query entries {
user {
id
baby {
id
entries {
id
parentType
childType
time
}
}
}
}
`;
const EntriesListWithData = graphql(entriesListQuery)(EntriesList);export default EntriesListWithData;
{entries
.sort((a,b) => a.time - b.time )
.map(entry => <li>{time}</li> );
}
TypeError: Cannot assign to read only property '1' of object '[object Array]'
query entries {
user {
id
baby {
id
entries(
orderBy: time_ASC
) {
id
parentType
childType
time
}
}
}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store