This file contains hidden or 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
export const typeDefinitions = ` | |
type Foo { | |
bar: String | |
baz: String | |
} | |
` |
This file contains hidden or 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
import { mergeSchemas } from 'graphql-tools' | |
import fooSchema from './foo' // export default makeExecutableSchema({ typeDefs: fooTypeDefinitions }) | |
import barSchema from './bar' // export default makeExecutableSchema({ typeDefs: barTypeDefinitions }) | |
export default mergeSchemas({ | |
schemas: [fooSchema, barSchema], | |
}) |
This file contains hidden or 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
import { makeExecutableSchema } from 'graphql-tools' | |
import merge from 'lodash.merge' | |
import { | |
queries as fooQueries, | |
resolvers as fooResolvers, | |
typeDefinitions as fooTypeDefinitions, | |
} from './foo/schema' | |
import { |
This file contains hidden or 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
type User { | |
id: String! | |
name: String @deprecated(reason: "Use firstname instead.") | |
firstname: String | |
age: Int | |
} |
This file contains hidden or 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
# root query | |
type Query { | |
# query user by id | |
user( | |
# user id | |
id: String | |
): User | |
# query users | |
users: [User] |
This file contains hidden or 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
const typeDefs = [` | |
# # Root query # | |
# ## Domain ## | |
# service.loremipsum.com/graphql | |
# ## Header ## | |
# Authorization : Bearer lorem ipsum | |
type Query { | |
user(id: String): User | |
users: [User] | |
} |
This file contains hidden or 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
const logRequest = { | |
applyAfterware({ response }, next) { | |
if (response.status === 200) { | |
console.log('log from afterware.') | |
} | |
next() | |
} | |
} | |
const networkInterface = createNetworkInterface({ |
This file contains hidden or 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
import React, { Component } from 'react' | |
import { graphql, compose } from 'react-apollo' | |
import { Button } from 'antd' | |
import mutationState from 'react-apollo-mutation-state' | |
import Loading from './common/Loading' | |
import Error from './common/Error' | |
import { fetchAllImages as query } from '../queries/image' | |
import { createImage as mutation } from '../mutations/image' | |
class Gallery extends Component { |
This file contains hidden or 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
class Gallery extends Component { | |
state = { | |
loading: false, | |
} | |
createImageAndReFetch = () => { | |
this.setState({ loading: true }) | |
this.props.createImage({ | |
refetchQueries: [{ query }] | |
}) |
This file contains hidden or 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
class Gallery extends Component { | |
render() { | |
const { loading, error, allImages } = this.props.data | |
if (loading) return <Loading /> | |
else if (error) return <Error /> | |
return ( | |
<div> | |
{ | |
allImages.map(image => <img key={image.id} src={image.url} />) |