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 { RocketData, RocketVars } from './types'; | |
const GET_ROCKET_INVENTORY = gql` | |
query getRocketInventory($year: Int!) { | |
rocketInventory(year: $year) { | |
id | |
year | |
} | |
} | |
`; |
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
function Message() { | |
const [saveMessage, { loading }] = useMutation(SAVE_MESSAGE); | |
const [deleteMessage] = useMutation(DELETE_MESSAGE); | |
const { data } = useQuery(GET_MESSAGE); | |
return ( | |
<div> | |
<p> | |
{loading | |
? 'Loading ...' |
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 LAST_LAUNCH = gql` | |
query lastLaunch { | |
launch { | |
id | |
timestamp | |
} | |
} | |
`; | |
export function LastLaunch() { |
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 client = new ApolloClient({ | |
cache: new InMemoryCache(), | |
link: new HttpLink({ | |
uri: 'http://localhost:4000/graphql', | |
}), | |
resolvers: { | |
Launch: { | |
isInCart: (launch, _args, { cache }) => { | |
const { cartItems } = cache.readQuery({ | |
query: GET_CART_ITEMS |
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 GET_LAUNCH_DETAILS = gql` | |
query LaunchDetails($launchId: ID!) { | |
launch(id: $launchId) { | |
isInCart @client | |
site | |
rocket { | |
type | |
} | |
} | |
} |
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 client = new ApolloClient({ | |
cache: new InMemoryCache(), | |
link: new HttpLink({ | |
uri: 'http://localhost:4000/graphql', | |
}), | |
typeDefs: gql` | |
extend type Launch { | |
isInCart: Boolean! | |
} | |
`, |
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 client = new ApolloClient({ | |
// ... | |
resolvers: { | |
RentalCar: { | |
numberAvailable(car) => { | |
// Call into a separate car inventory tracking system, | |
// to get up to date car availibility. | |
return CarTracker.isCarAvailable(car.id); | |
}, | |
}, |
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
// Example ApolloClient config including a fullName resolver to | |
// combine first and last names. | |
const client = new ApolloClient({ | |
// ... | |
resolvers: { | |
Customer: { | |
fullName(customer) => { | |
return `${customer.firstName} ${customer.lastName}`; | |
}, | |
}, |
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
// Example ApolloClient config showing a Mutation resolver. | |
const client = new ApolloClient({ | |
cache: new InMemoryCache(), | |
resolvers: { | |
Mutation: { | |
toggleTodo: (_root, variables, { cache, getCacheKey }) => { | |
const id = getCacheKey({ __typename: 'TodoItem', id: variables.id }) | |
const fragment = gql` | |
fragment completeTodo on TodoItem { | |
completed |
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 Loadable from 'react-loadable'; | |
import Loading from './components/Loading'; | |
export const Stats = Loadable({ | |
loader: () => import('./components/stats/Stats'), | |
loading: Loading, | |
}); |
NewerOlder