Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package-lock.json

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

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
"name": "hooks-graphql",
"version": "0.0.38",
"description": "A sample integration of React hooks into graphql",
"keywords": ["hooks", "react", "graphql"],
"keywords": [
"hooks",
"react",
"graphql"
],
"author": "Shruti Kapoor",
"main": "index.js",
"dependencies": {
Expand All @@ -11,6 +15,7 @@
"apollo-client": "^2.6.0",
"apollo-client-preset": "1.0.5",
"apollo-link-http": "^1.5.14",
"eslint-plugin-react-hooks": "^1.7.0",
"graphiql": "^0.13.0",
"graphql": "0.11.7",
"graphql-tag": "^2.10.1",
Expand Down
18 changes: 5 additions & 13 deletions src/components/Home.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React, { useEffect, useContext} from "react";
import {graphql} from "react-apollo";
import {graphql, Mutation} from "react-apollo";
import Container from "muicss/lib/react/container";
import { singleActor } from '../graphql/queries'
import { GET_SONGS } from '../graphql/queries'
import AddSong from './AddSong'
import { DELETE_SONG } from '../graphql/mutations'

import SongItem from './SongItem'
import Context from '../context'

const Home = ({ data: { loading, error, songs } }) => {
Expand All @@ -26,17 +29,6 @@ const Home = ({ data: { loading, error, songs } }) => {
<h3>{song.actor}</h3>
<p>{song.lyrics}</p>
</div>
{/*<Mutation*/}
{/*mutation={DELETE_SONG}>*/}
{/*{ (deleteSong) =>*/}
{/*<button onClick={() => {*/}
{/*dispatch({type: "DELETE_CONTENT", payload: {id: song.id}});*/}
{/*deleteSong({variables: {id: {id: song.id}}});*/}
{/*}}>*/}
{/*Remove song*/}
{/*</button>*/}
{/*}*/}
{/*</Mutation>*/}
</div>
))}
</div>
Expand Down
11 changes: 11 additions & 0 deletions src/components/SongItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";

const SongItem = (song) => (
<div className={'text-wrapper'}>
<h1>{song.name}</h1>
<h3>{song.actor}</h3>
<p>{song.lyrics}</p>
</div>
);

export default SongItem
6 changes: 4 additions & 2 deletions src/graphql/queries.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import gql from "graphql-tag";

export const singleActor = gql`
query songs($actor: String) {
export const GET_SONGS = gql`
query albums($actor: String) {
date
artwork
songs(where: { actor: $actor }) {
name
id
Expand Down