Chapter7 - Administration
pedrosmmc opened this issue · 4 comments
Hi!
After finishing code to 7-15 and starting the app, the browser shows this error:
TypeError: orders is undefined
props
src/admin/OrdersConnector.js:16
13 | {
14 | options: (props) => ({variables: vars}),
15 | props: ({data: {loading, orders, refetch}}) => ({
16 | totalSize: loading ? 0 : orders.totalSize,
| ^ 17 | orders: loading ? [] : orders.orders,
18 | currentPage: vars.page,
19 | pageCount: loading ? 0 : Math.ceil(orders.totalSize / vars.pageSize),
...
I'm stuck in this part :( and need some help here.
Hi,
I'd also recommend to check a response object from the graphql.
Open developer tools in your preferred web browser navigate to Network tab and reload the http://localhost:3000/admin (your server must be switched on by npm start).
You should see received responses from the server. Select graphql response and on the right site navigate to Preview tab.
You should see there an object, which contains the orders object and an errors array. Expand the errors array and read the error messages.
Remember that after changes you'll perform in graphql (serverQueriesSchema.graphql, serverMutationsSchema.graphql, serverQueriesResolver.js, serverMutationsResolver.js, etc.), you must restart the server.
I am stuck with the same error:
TypeError: Cannot read property 'totalSize' of undefined
props
src/admin/OrdersConnector.js:13
10 | {
11 | options: props => ({ variables: vars}),
12 | props: ({data: { loading, orders, refetch }}) => ({
> 13 | totalSize: loading ? 0 : orders.totalSize,
| ^ 14 | orders: loading ? []: orders.orders,
15 | currentPage: vars.page,
16 | pageCount: loading ? 0 : Math.ceil(orders.totalSize / vars.pageSize),
Were you able to fix it @pedrosmmc ?
I figured out what was wrong for me. I tried querying for orders using the GraphiQL interface and was receiving errors. There was a bug in my serverQueriesResolver.js file that was causing the problems. Once I made these changes and restarted the server as per @vizdatom everything worked as expected.
Same error:
TypeError: Cannot read property 'totalSize' of undefined
12 | {
13 | options: (props) => ({ variables: vars }),
14 | props: ({data: { loading, orders, refetch }}) => ({
> 15 | totalSize: loading ? 0 : orders.totalSize,
| ^ 16 | orders: loading ? []: orders.orders,
17 | currentPage: vars.page,
18 | pageCount: loading ? 0 : Math.ceil(orders.totalSize / vars.pageSize),