Skip to content

Commit

Permalink
Updates for item children GraphQL edge schema change (now uses item s…
Browse files Browse the repository at this point in the history
…earch results pattern vs an array of items).
  • Loading branch information
ambrauer committed Apr 8, 2021
1 parent fc255d0 commit c58bb98
Show file tree
Hide file tree
Showing 5 changed files with 20,190 additions and 19,816 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@ query IntegratedDemoQuery($datasource: String!, $contextItem: String!) {

# List the children of the current route
children(hasLayout: true) {
id
# typing fragments can be used anywhere!
# so in this case, we're grabbing the 'pageTitle'
# field on all child route items.
...on AppRoute {
pageTitle {
jsonValue
value
results {
id
# typing fragments can be used anywhere!
# so in this case, we're grabbing the 'pageTitle'
# field on all child route items.
...on AppRoute {
pageTitle {
jsonValue
value
}
}
url{
path
}
}
url{
path
}
}
}
Expand Down
24 changes: 13 additions & 11 deletions samples/nextjs/src/components/graphql/GraphQL-ConnectedDemo.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,20 @@ query ConnectedDemoQuery($datasource: String!, $contextItem: String!) {

# List the children of the current route
children(hasLayout: true) {
id
# typing fragments can be used anywhere!
# so in this case, we're grabbing the 'pageTitle'
# field on all child route items.
...on AppRoute {
pageTitle {
jsonValue
value
results {
id
# typing fragments can be used anywhere!
# so in this case, we're grabbing the 'pageTitle'
# field on all child route items.
...on AppRoute {
pageTitle {
jsonValue
value
}
}
url{
path
}
}
url{
path
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const GraphQLConnectedDemo = (props: StyleguideComponentProps): JSX.Element => {
<br />
children:
<ul>
{data.contextItem.children.map((child) => {
{data.contextItem.children.results.map((child) => {
const routeItem = child as RouteItem;

return (
Expand Down
10 changes: 7 additions & 3 deletions samples/nextjs/src/components/graphql/GraphQL-IntegratedDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface DataSource {
id: string;
}

interface ContextItemChild {
interface Item {
id: string;
url: {
path: string;
Expand All @@ -43,13 +43,17 @@ interface ContextItemChild {
};
}

interface ItemSearchResults {
results: Item[];
}

interface GraphQlIntegratedDemoProps {
fields: {
data: {
datasource: DataSource;
contextItem: {
id: string;
children: ContextItemChild[];
children: ItemSearchResults;
pageTitle: {
value: string;
};
Expand Down Expand Up @@ -107,7 +111,7 @@ const GraphQLIntegratedDemo = (props: GraphQlIntegratedDemoProps): JSX.Element =
<br />
children:
<ul>
{contextItem.children.map((child: ContextItemChild) => (
{contextItem.children.results.map((child: Item) => (
<li key={child.id}>
<NextLink href={child.url.path}>
<a>{child.pageTitle.value}</a>
Expand Down
Loading

0 comments on commit c58bb98

Please sign in to comment.