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 { createClient } from "@libsql/client"; | |
import { fetch } from "@libsql/hrana-client"; | |
function sleep(ms: number) { | |
return new Promise((resolve) => setTimeout(resolve, ms)); | |
} | |
export async function retryOnceOnError(fn: any) { | |
try { | |
return await fn(); |
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 | |
} | |
} | |
` |
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() | |
} | |
} |
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! | |
} |
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 | |
}) |
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!' | |
} | |
} |
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! | |
} | |
` |
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 | |
} | |
} | |
` |
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> | |
)) |
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 | |
} | |
} | |
` |
NewerOlder