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 resolvers = { | |
| Query: { | |
| books: () => api.books, | |
| countries: () => api.countries | |
| }, | |
| }; |
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 from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| import './styles/index.css'; | |
| import App from './components/App'; | |
| import * as serviceWorker from './serviceWorker'; | |
| import { ApolloProvider } from 'react-apollo'; | |
| import { ApolloClient } from 'apollo-client'; | |
| import { createHttpLink } from 'apollo-link-http'; | |
| import { InMemoryCache } from 'apollo-cache-inmemory'; |
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 { Query } from 'react-apollo' | |
| import gql from 'graphql-tag' | |
| const countiresQuery = gql` { | |
| countries { | |
| name | |
| population | |
| inNato | |
| } | |
| }` |
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 '../styles/App.css'; | |
| import { Query } from 'react-apollo' | |
| import gql from 'graphql-tag' | |
| const countiresQuery = gql` { | |
| countries { | |
| name | |
| population |
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 { gql } = require('apollo-server'); | |
| const typeDefs = gql` | |
| type Country { | |
| name: String! | |
| population: String! | |
| inNato: Boolean! | |
| id: 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
| const api = require('./server/api'); | |
| const typeDefs = require('./server/schema'); | |
| const resolvers = { | |
| Query: { | |
| countries: () => api.countries, | |
| country: (obj, args) => { | |
| for (const record of api.countries) { | |
| if (record.id === args.id) { | |
| return record; |
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
| // Start imports for React Apollo GraphQL Queries | |
| import { ApolloProvider } from 'react-apollo'; | |
| import { ApolloClient } from 'apollo-client'; | |
| import { createHttpLink } from 'apollo-link-http'; | |
| import { InMemoryCache } from 'apollo-cache-inmemory'; | |
| // End of imports for React Apollo GraphQL Queries | |
| // Start imports for GraphQL Hooks Queries | |
| import { GraphQLClient, ClientContext } from 'graphql-hooks'; | |
| import memCache from 'graphql-hooks-memcache'; |
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
| // Context for React Apollo | |
| const httpLinkReactApollo = createHttpLink({ | |
| uri: 'http://localhost:4000' | |
| }); | |
| const clientReactApollo = new ApolloClient({ | |
| link: httpLinkReactApollo, | |
| cache: new InMemoryCache() | |
| }); | |
| // Context for GraphQL Hooks |
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 from 'react'; | |
| import { Query } from 'react-apollo' | |
| import gql from 'graphql-tag' | |
| const countryQuery = gql` | |
| query($id: Int!) { | |
| country(id: $id) { | |
| name | |
| population |
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 from 'react'; | |
| import { useQuery } from 'graphql-hooks'; | |
| const countryQuery = ` | |
| query($id: Int!) { | |
| country(id: $id) { | |
| name | |
| population | |
| } | |
| } |