Skip to content

Commit

Permalink
Updated graphql API to support v1.7.2 (#35896)
Browse files Browse the repository at this point in the history
## Documentation / Examples
- [X] Make sure the linting passes by running `yarn lint`
Graphql API has updated with use of nodes, this bugfix updates these specifications.


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
  • Loading branch information
indicozy and ijjk committed May 29, 2022
1 parent 69cc9b3 commit c7ab218
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
8 changes: 4 additions & 4 deletions examples/cms-wordpress/components/avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import Image from 'next/image'

export default function Avatar({ author }) {
const name = author
? author.firstName && author.lastName
? `${author.firstName} ${author.lastName}`
: author.name
? author.node.firstName && author.node.lastName
? `${author.node.firstName} ${author.node.lastName}`
: author.node.name
: null

return (
<div className="flex items-center">
<div className="w-12 h-12 relative mr-4">
<Image
src={author.avatar.url}
src={author.node.avatar.url}
layout="fill"
className="rounded-full"
alt={name}
Expand Down
2 changes: 1 addition & 1 deletion examples/cms-wordpress/components/cover-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function CoverImage({ title, coverImage, slug }) {
width={2000}
height={1000}
alt={`Cover Image for ${title}`}
src={coverImage?.sourceUrl}
src={coverImage?.node.sourceUrl}
className={cn('shadow-small', {
'hover:shadow-medium transition-shadow duration-200': slug,
})}
Expand Down
28 changes: 19 additions & 9 deletions examples/cms-wordpress/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,18 @@ export async function getAllPostsForHome(preview) {
slug
date
featuredImage {
sourceUrl
node {
sourceUrl
}
}
author {
name
firstName
lastName
avatar {
url
node {
name
firstName
lastName
avatar {
url
}
}
}
}
Expand Down Expand Up @@ -121,10 +125,14 @@ export async function getPostAndMorePosts(slug, preview, previewData) {
slug
date
featuredImage {
sourceUrl
node {
sourceUrl
}
}
author {
...AuthorFields
node {
...AuthorFields
}
}
categories {
edges {
Expand Down Expand Up @@ -156,7 +164,9 @@ export async function getPostAndMorePosts(slug, preview, previewData) {
excerpt
content
author {
...AuthorFields
node {
...AuthorFields
}
}
}
}
Expand Down

0 comments on commit c7ab218

Please sign in to comment.