@@ -2,60 +2,63 @@ import React from 'react';
22import ReactDOM from 'react-dom' ;
33import { ApolloProvider } from 'react-apollo' ;
44import { ApolloClient } from 'apollo-client' ;
5- // import { HttpLink } from 'apollo-link-http';
5+ import { HttpLink } from 'apollo-link-http' ;
66import { InMemoryCache } from 'apollo-cache-inmemory' ;
77
88import { SchemaLink } from 'apollo-link-schema' ;
99import {
1010 makeExecutableSchema ,
11- // introspectSchema,
11+ introspectSchema ,
1212} from 'graphql-tools' ;
1313
14- // import { printSchema } from 'graphql/utilities/schemaPrinter';
14+ import { printSchema } from 'graphql/utilities/schemaPrinter' ;
1515
1616import App from './App' ;
17- import { schema , resolvers } from './schema' ;
17+ import {
18+ // schema,
19+ resolvers ,
20+ } from './schema' ;
1821
1922import registerServiceWorker from './registerServiceWorker' ;
2023
21- // async function render() {
22- const cache = new InMemoryCache ( ) ;
24+ async function render ( ) {
25+ const cache = new InMemoryCache ( ) ;
2326
24- // const GITHUB_BASE_URL = 'https://api.github.com/graphql';
27+ const GITHUB_BASE_URL = 'https://api.github.com/graphql' ;
2528
26- // const httpLink = new HttpLink({
27- // uri: GITHUB_BASE_URL,
28- // headers: {
29- // authorization: `Bearer ${
30- // process.env.REACT_APP_GITHUB_PERSONAL_ACCESS_TOKEN
31- // }`,
32- // },
33- // });
29+ const httpLink = new HttpLink ( {
30+ uri : GITHUB_BASE_URL ,
31+ headers : {
32+ authorization : `Bearer ${
33+ process . env . REACT_APP_GITHUB_PERSONAL_ACCESS_TOKEN
34+ } `,
35+ } ,
36+ } ) ;
3437
35- // const schema = await introspectSchema(httpLink);
38+ const schema = await introspectSchema ( httpLink ) ;
3639
37- const executableSchema = makeExecutableSchema ( {
38- // typeDefs: printSchema(schema),
39- typeDefs : schema ,
40- resolvers,
41- // resolverValidationOptions: {
42- // requireResolversForResolveType: false,
43- // },
44- } ) ;
45-
46- const client = new ApolloClient ( {
47- link : new SchemaLink ( { schema : executableSchema } ) ,
48- cache,
49- } ) ;
50-
51- ReactDOM . render (
52- < ApolloProvider client = { client } >
53- < App />
54- </ ApolloProvider > ,
55- document . getElementById ( 'root' ) ,
56- ) ;
57- // }
58-
59- // render();
40+ const executableSchema = makeExecutableSchema ( {
41+ typeDefs : printSchema ( schema ) ,
42+ // typeDefs: schema,
43+ resolvers,
44+ resolverValidationOptions : {
45+ requireResolversForResolveType : false ,
46+ } ,
47+ } ) ;
48+
49+ const client = new ApolloClient ( {
50+ link : new SchemaLink ( { schema : executableSchema } ) ,
51+ cache,
52+ } ) ;
53+
54+ ReactDOM . render (
55+ < ApolloProvider client = { client } >
56+ < App />
57+ </ ApolloProvider > ,
58+ document . getElementById ( 'root' ) ,
59+ ) ;
60+ }
61+
62+ render ( ) ;
6063
6164registerServiceWorker ( ) ;
0 commit comments