File tree Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
2
import LinkList from './LinkList'
3
+ import CreateLink from './CreateLink'
3
4
4
- export default ( ) => < LinkList />
5
+ export default ( ) => < CreateLink />
Original file line number Diff line number Diff line change
1
+ import React , { Component } from 'react'
2
+ import { Mutation } from 'react-apollo'
3
+ import gql from 'graphql-tag'
4
+
5
+ const POST_MUTATION = gql `
6
+ mutation PostMutation($description: String!, $url: String!) {
7
+ post(description: $description, url: $url) {
8
+ id
9
+ createdAt
10
+ url
11
+ description
12
+ }
13
+ }
14
+ `
15
+
16
+ class CreateLink extends Component {
17
+ state = {
18
+ description : '' ,
19
+ url : ''
20
+ }
21
+
22
+ render ( ) {
23
+ const { description, url } = this . state
24
+ return (
25
+ < div >
26
+ < div className = "flex flex-column mt3" >
27
+ < input
28
+ className = "mb2"
29
+ value = { description }
30
+ onChange = { e => this . setState ( { description : e . target . value } ) }
31
+ type = "text"
32
+ placeholder = "A description for the link"
33
+ />
34
+ < input
35
+ className = "mb2"
36
+ value = { url }
37
+ onChange = { e => this . setState ( { url : e . target . value } ) }
38
+ type = "text"
39
+ placeholder = "The URL for the link"
40
+ />
41
+ </ div >
42
+ < Mutation mutation = { POST_MUTATION } variables = { { description, url } } >
43
+ { postMutation => < button onClick = { postMutation } > Submit</ button > }
44
+ </ Mutation >
45
+ </ div >
46
+ )
47
+ }
48
+ }
49
+
50
+ export default CreateLink
You can’t perform that action at this time.
0 commit comments