Skip to content
Permalink
Browse files

nonworking apollo

  • Loading branch information...
tadasant committed Nov 3, 2018
1 parent 70772b2 commit aa21d5b36f32535f9eddd0815934e0199464c047
Showing with 107 additions and 16 deletions.
  1. +8 −0 app/package.json
  2. +29 −16 app/src/App.js
  3. +8 −0 app/src/components/Routing.js
  4. +25 −0 app/src/components/game/GameScreen.js
  5. +37 −0 graphql.config.json
@@ -3,7 +3,15 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"apollo-cache-inmemory": "^1.3.9",
"apollo-client": "^2.4.5",
"apollo-link": "^1.2.3",
"apollo-link-error": "^1.1.1",
"apollo-link-http": "^1.5.5",
"gql": "^1.1.2",
"graphql": "^14.0.2",
"react": "^16.6.0",
"react-apollo": "latest",
"react-dom": "^16.6.0",
"react-scripts": "2.1.1"
},
@@ -1,23 +1,36 @@
import React, { Component } from 'react';
import {InMemoryCache} from 'apollo-cache-inmemory';
import ApolloClient from 'apollo-client/ApolloClient';
import * as ApolloLink from 'apollo-link';
import {onError} from 'apollo-link-error';
import {HttpLink} from 'apollo-link-http';
import React, {Component} from 'react';
import {ApolloProvider} from 'react-apollo';
import Routing from './components/Routing';

const client = new ApolloClient({
link: ApolloLink.from([
onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors)
graphQLErrors.map(({ message, locations, path }) =>
console.log(
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`,
),
);
if (networkError) console.log(`[Network error]: ${networkError}`);
}),
new HttpLink({
uri: 'https://where-in-the-world-hq.herokuapp.com/v1alpha1/graphql',
})
]),
cache: new InMemoryCache()
});

class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
<ApolloProvider client={client}>
<Routing/>
</ApolloProvider>
);
}
}
@@ -0,0 +1,8 @@
import * as React from 'react';
import GameScreen from './game/GameScreen';

const Routing = () => (
<GameScreen/>
);

export default Routing;
@@ -0,0 +1,25 @@
import * as React from 'react';
import {graphql} from 'graphql';
import gql from 'gql';

const GAMES_QUERY = gql`
query {
Game {
id
}
}
`;

const GameScreen = props => (
<div>
{props.data.Game && props.data.Game.id}
</div>
);

const withGames = graphql(GAMES_QUERY, {
options: ({ episode }) => ({
variables: { episode }
}),
});

export default withGames(GameScreen);
@@ -0,0 +1,37 @@
{

"README_schema" : "Specifies how to load the GraphQL schema that completion, error highlighting, and documentation is based on in the IDE",
"schema": {

"README_file" : "Remove 'file' to use request url below. A relative or absolute path to the JSON from a schema introspection query, e.g. '{ data: ... }' or a .graphql/.graphqls file describing the schema using GraphQL Schema Language. Changes to the file are watched.",

"README_request" : "To request the schema from a url instead, remove the 'file' JSON property above (and optionally delete the default graphql.schema.json file).",
"request": {
"url" : "https://where-in-the-world-hq.herokuapp.com/v1alpha1/graphql",
"method" : "POST",
"README_postIntrospectionQuery" : "Whether to POST an introspectionQuery to the url. If the url always returns the schema JSON, set to false and consider using GET",
"postIntrospectionQuery" : true,
"README_options" : "See the 'Options' section at https://github.com/then/then-request",
"options" : {
"headers": {
"user-agent" : "JS GraphQL"
}
}
}

},

"README_endpoints": "A list of GraphQL endpoints that can be queried from '.graphql' files in the IDE",
"endpoints" : [
{
"name": "Default (http://localhost:8080/graphql)",
"url": "https://where-in-the-world-hq.herokuapp.com/v1alpha1/graphql",
"options" : {
"headers": {
"user-agent" : "JS GraphQL"
}
}
}
]

}

0 comments on commit aa21d5b

Please sign in to comment.
You can’t perform that action at this time.