- The GitHub branch of this spike in Vets-API repo
- Why GraphQL?
- GraphQL best practices in production, at scale:
- RailsConf 2018: The GraphQL Way: A new path for JSON APIs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"data": { | |
"type": "will_paginate_collections", | |
"attributes": { | |
"items": [ | |
{ | |
"item": { | |
"id": 156, | |
"type": "Accomplishment", | |
"description": "Flexitarian hoodie tousled skateboard umami. Chicharrones single-origin coffee swag wayfarers semiotics kickstarter. Quinoa before they sold out godard jean shorts.", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
First Name | Last Name | Birthday | Work Anniversary | Team | ||
---|---|---|---|---|---|---|
[email protected] | John | Smith | 04/29/1995 | 02/26/2015 | Sales | |
[email protected] | Frank | Thompson | 11/12/1977 | Operations | ||
[email protected] | Susan | Sanchez | 12/15/2018 | |||
[email protected] | Dennis | Meeker | 01/05/1970 | 09/28/1992 | Operations | |
[email protected] | Admin | Sanchez | 11/12/1977 | 12/15/2018 | ||
[email protected] | Admin | Sanchez | 11/12/1977 | 12/15/2018 | ||
[email protected] | Harry | Levine | 11/12/1977 | 12/15/2018 | ||
[email protected] | Malte | Muenke | 11/12/1977 | 12/15/2018 | ||
[email protected] | Nate | Vogels | 11/12/1977 | 12/15/2018 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"swagger": "2.0", | |
"info": { | |
"version": "1.0.0", | |
"title": "vets.gov API", | |
"description": "The API for managing vets.gov", | |
"termsOfService": "", | |
"contact": { | |
"name": "vets.gov team" | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/components/NewPost.js | |
... | |
import { passCsrfToken } from '../util/helpers' | |
class NewPost extends React.Component { | |
state = { | |
title: '', | |
body: '' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/util/helpers.js | |
function csrfToken(document) { | |
return document.querySelector('[name="csrf-token"]').content; | |
} | |
export function passCsrfToken(document, axios) { | |
axios.defaults.headers.common['X-CSRF-TOKEN'] = csrfToken(document); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/components/NewPost.js | |
handleSubmit = event => { | |
event.preventDefault(); | |
const post = { | |
title: this.state.title, | |
body: this.state.body | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/components/NewPost.js | |
... | |
handleSubmit = event => { | |
event.preventDefault(); | |
} | |
render() { | |
return ( | |
<div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/components/NewPost.js | |
import axios from 'axios' | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/javascript/components/NewPost.js | |
import React from 'react' | |
class NewPost extends React.Component { | |
state = { | |
title: '', | |
body: '' | |
} |
NewerOlder