View apollo-mocks-app-exchange-rates-name-field.js
This file contains 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 EXCHANGE_RATES = gql` | |
{ | |
rates(currency: "USD") { | |
rate | |
name | |
} | |
} | |
` |
View apollo-mocks-app-exchange-rates-new-name-resolver.js
This file contains 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
// imports... | |
import faker from 'faker' | |
// const typeDefs = ... | |
const resolvers = { | |
ExchangeRate: { | |
name: () => faker.finance.currencyName() | |
} | |
} |
View apollo-mocks-app-with-mocks.js
This file contains 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 ApolloClient from 'apollo-boost' | |
import { ApolloProvider } from '@apollo/react-hooks' | |
import Rates from './Rates' | |
import gql from 'graphql-tag' | |
const typeDefs = gql` | |
extend type ExchangeRate { | |
name: String! | |
} |
View apollo-mocks-app-client-with-mocks.js
This file contains 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 client = new ApolloClient({ | |
uri: 'https://48p1r2roz4.sse.codesandbox.io', | |
typeDefs, | |
resolvers | |
}) |
View apollo-mocks-app-resolvers.js
This file contains 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 = { | |
ExchangeRate: { | |
name: () => 'This is a custom name!' | |
} | |
} |
View apollo-mocks-app-type-defs.js
This file contains 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 = gql` | |
extend type ExchangeRate { | |
name: String! | |
} | |
` |
View apollo-mocks-app-exchange-rates-new-name-field.js
This file contains 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 EXCHANGE_RATES = gql` | |
{ | |
rates(currency: "USD") { | |
rate | |
name @client | |
} | |
} | |
` |
View apollo-mocks-app-exchange-rates-name-mapping.js
This file contains 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
return data.rates.map(({ name, rate }) => ( | |
<ul key={name}> | |
<li> | |
<strong>{name}</strong>: {rate} | |
</li> | |
</ul> | |
)) |
View apollo-mocks-app-exchange-rates-new-name-field.js
This file contains 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 EXCHANGE_RATES = gql` | |
{ | |
rates(currency: "USD") { | |
currency | |
rate | |
name @client | |
} | |
} | |
` |
View apollo-mocks-app-exchange-rates-import.js
This file contains 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
// imports... | |
import Rates from './Rates' | |
// client = ... | |
function App() { | |
return ( | |
<ApolloProvider client={client}> | |
... | |
<Rates /> |
NewerOlder