Skip to content

Commit

Permalink
make some changes to fix NextJS error (vercel/next.js#8617)
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultboursier committed Dec 1, 2019
1 parent bafd7a5 commit 72b0682
Show file tree
Hide file tree
Showing 11 changed files with 266 additions and 35 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,3 @@ dist

# TernJS port file
.tern-port

# Relay
__generated__/
schemas/schema.graphql
6 changes: 3 additions & 3 deletions components/Item.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback, useState, useContext } from "react";
import { ListGroupItem } from "reactstrap";
import ItemQuery from "../queries/ItemQuery";
import ItemQuery, { ItemQueryRenderer } from "../queries/itemQuery";

const Item = ({ item, isSelected, onClick }) => (
<ListGroupItem
Expand All @@ -12,7 +12,7 @@ const Item = ({ item, isSelected, onClick }) => (
>
{item.name}
{isSelected && (
<ItemQuery gtfsId={item.gtfsId}>
<ItemQueryRenderer gtfsId={item.gtfsId}>
{({ error, props }) => {
if (error) {
return <div>An error occured: "{error.message}"</div>;
Expand All @@ -26,7 +26,7 @@ const Item = ({ item, isSelected, onClick }) => (
<div>&nbsp;&nbsp;&nbsp;# Timezone: {props.agency.timezone}</div>
);
}}
</ItemQuery>
</ItemQueryRenderer>
)}
</ListGroupItem>
);
Expand Down
60 changes: 60 additions & 0 deletions containers/__generated__/ItemContainer_item.graphql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions containers/__generated__/ItemsContainer_items.graphql.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"dev": "npm run relay && next",
"build": "npm run relay && next build",
"build": "next build",
"start": "next start",
"relay": "npm run relay:schema && npm run relay:compile",
"relay:compile": "relay-compiler",
Expand Down
9 changes: 1 addition & 8 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@ import { ReactRelayContext } from "react-relay";
import { Button, Jumbotron } from "reactstrap";
import { withData } from "../relay/withData";
import ItemsContainer from "../containers/ItemsContainer";

const rootQuery = graphql`
query pagesRootQuery {
agencies {
...ItemsContainer_items
}
}
`;
import { rootQuery } from "../queries/rootQuery";

const IndexPage = ({ agencies, operationToRetain }) => {
const { environment } = useContext(ReactRelayContext);
Expand Down
10 changes: 4 additions & 6 deletions queries/ItemQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { useContext } from "react";
import { QueryRenderer, ReactRelayContext } from "react-relay";
import graphql from "babel-plugin-relay/macro";

const query = graphql`
query ItemQuery($id: String!) {
export const itemQuery = graphql`
query itemQueryQuery($id: String!) {
agency(id: $id) {
id
phone
Expand All @@ -13,19 +13,17 @@ const query = graphql`
}
`;

const ItemQuery = ({ children, gtfsId: id }) => {
export const ItemQueryRenderer = ({ children, gtfsId: id }) => {
const { environment } = useContext(ReactRelayContext);

return (
<QueryRenderer
environment={environment}
query={query}
query={itemQuery}
render={children}
variables={{
id
}}
/>
);
};

export default ItemQuery;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 72b0682

Please sign in to comment.