Skip to content

Commit

Permalink
Add frontend support for modified queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Lavikjo committed Oct 8, 2020
1 parent 31ac00c commit 9a3057c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions osa8/library-frontend/src/components/Authors.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const Authors = (props) => {

useEffect(() => {
if (result.data) {
console.log(result.data)
setAuthors(result.data.allAuthors)
}
}, [result])
Expand Down
2 changes: 1 addition & 1 deletion osa8/library-frontend/src/components/Books.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Books = (props) => {
{books.map((a) => (
<tr key={a.title}>
<td>{a.title}</td>
<td>{a.author}</td>
<td>{a.author.name}</td>
<td>{a.published}</td>
</tr>
))}
Expand Down
10 changes: 8 additions & 2 deletions osa8/library-frontend/src/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ export const ALL_BOOKS = gql`
query {
allBooks {
title
author
author {
name
born
}
published
}
}
Expand All @@ -34,7 +37,10 @@ export const ADD_BOOK = gql`
genres: $genres
) {
title
author
author {
name
born
}
id
published
genres
Expand Down

0 comments on commit 9a3057c

Please sign in to comment.