Skip to content

Instantly share code, notes, and snippets.

View Descartess's full-sized avatar

Paul Nyondo Descartess

  • Kampala
View GitHub Profile
const Schema = [
`
type Team {
id: Int!
profile:String!
name:String!
users: [User]
}
type Address {
streetAddress:String!
axios.get('http://localhost:8000/users/1/friends')
.then(response => console.log(response.data))
.catch(err => console.log(err))
{
"user": {
"name": "Batman",
"friends": [
{
"name": "Wonder woman",
"villains": [{"name": "Aries"}]
},
{
"name": "Flash",
{
users {
name
friends {
name
villains{
name
}
}
}
@Descartess
Descartess / data.json
Last active October 9, 2017 18:43
Query data
{
"username": "Batman",
"firstname": "Bruce",
"lastname": "Wayne",
"DOB": "2/10/1983",
"email":"batman@gotham.dc",
"friends": ["Wonder woman", "Flash", "James Gordon" ],
"status": "Single and violently searching",
"villains":["Joker", "Bane", "Penguin"]
}
export const getBucketLists = () => ({
type: 'GET_BUCKETLISTS',
payload: instance.get('/bucketlists'),
});
export const getBucketLists = () => {
return (dispatch) => {
dispatch({type: "GET_BUCKETLISTS"});
instance.get('/bucketlists')
.then((response) => {
dispatch({type: "GET_BUCKETLISTS_FULFILLED", payload: response.data});
})
.catch((err) => {
dispatch({type: "GET_BUCKETLISTS_REJECTED", payload: err }});
});
// axiosconfig.js
import axios from 'axios';
import store from './store';
// configure base url
const instance = axios.create({
baseURL: 'http://localhost:5000',
});
// intercept requests and add authorization token
// storeconfig.js
import { createStore, applyMiddleware } from 'redux';
import { logger } from 'redux-logger';
import promiseMiddleware from 'redux-promise-middleware';
import reducers from '../reducers';
const middleware = applyMiddleware(promiseMiddleware(), logger);
const store = createStore(reducers, middleware);
import configureStore from 'redux-mock-store';
import promiseMiddleware from 'redux-promise-middleware';
import moxios from 'moxios';
import * as actions from '../../actions';
import instance from '../../config/axiosconfig';
describe('async actions', () => {
const middlewares = [promiseMiddleware()];
const mockStore = configureMockStore(middlewares);