Skip to content

Commit a1437fa

Browse files
events variables in graphql queries
1 parent 08d4443 commit a1437fa

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

frontend/src/pages/Events.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ export default class Events extends Component {
5252

5353
const requestBody = {
5454
query: `
55-
mutation {
55+
mutation CreateEvent($title: String!, $description: String!, $price: Float!, $date: String!){
5656
createEvent(eventInput: {
57-
title: "${title}",
58-
description: "${description}",
59-
date: "${date}",
60-
price: ${price}
57+
title: $title,
58+
description: $description,
59+
date: $date,
60+
price: $price
6161
})
6262
{
6363
_id
@@ -68,6 +68,12 @@ export default class Events extends Component {
6868
}
6969
}
7070
`,
71+
variables: {
72+
title,
73+
price,
74+
date,
75+
description,
76+
},
7177
};
7278

7379
const token = this.context.token;

0 commit comments

Comments
 (0)