Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Make docs code consistent with fullstack tut code.
Browse files Browse the repository at this point in the history
  • Loading branch information
stemmlerjs committed Dec 19, 2019
1 parent 958971f commit d7ad7ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
15 changes: 6 additions & 9 deletions docs/source/tutorial/local-state.mdx
Expand Up @@ -42,7 +42,7 @@ export const typeDefs = gql`
}
extend type Mutation {
addOrRemoveFromCart(id: ID!): [Launch]
addOrRemoveFromCart(id: ID!): [ID!]!
}
`;

Expand Down Expand Up @@ -156,8 +156,7 @@ import gql from 'graphql-tag';
import { Header, Loading } from '../components'; // preserve-line
import { CartItem, BookTrips } from '../containers'; // preserve-line
import { RouteComponentProps } from '@reach/router';
import { QueryResult } from '@apollo/react-common';
import { GetCartItems } from './__generated__/GetCartItems';
import * as GetCartItemsTypes from './__generated__/GetCartItems';

export const GET_CART_ITEMS = gql`
query GetCartItems {
Expand All @@ -176,11 +175,9 @@ Next, we call `useQuery` and bind it to our `GetCartItems` query:
interface CartProps extends RouteComponentProps {}

const Cart: React.FC<CartProps> = () => {
const {
data,
loading,
error
}: QueryResult<GetCartItems, any> = useQuery<GetCartItems, any>(GET_CART_ITEMS);
const { data, loading, error } = useQuery<
GetCartItemsTypes.GetCartItems
>(GET_CART_ITEMS);

if (loading) return <Loading />;
if (error) return <p>ERROR: {error.message}</p>;
Expand Down Expand Up @@ -246,7 +243,7 @@ interface AppResolvers extends Resolvers {
export const resolvers: AppResolvers = { // highlight-line
Launch: {
isInCart: (launch: LaunchTileTypes.LaunchTile, _, { cache }): boolean => {
const queryResult = cache.readQuery<GetCartItemTypes.GetCartItems, any>({
const queryResult = cache.readQuery<GetCartItemTypes.GetCartItems>({
query: GET_CART_ITEMS
});
if (queryResult) {
Expand Down
15 changes: 6 additions & 9 deletions docs/source/tutorial/queries.mdx
Expand Up @@ -33,7 +33,6 @@ import gql from 'graphql-tag';

import { LaunchTile, Header, Button, Loading } from '../components'; // preserve-line
import { RouteComponentProps } from '@reach/router';
import { QueryResult } from '@apollo/react-common';
import * as GetLaunchListTypes from './__generated__/GetLaunchList';

const GET_LAUNCHES = gql`
Expand Down Expand Up @@ -74,10 +73,10 @@ const Launches: React.FC<LaunchesProps> = () => {
data,
loading,
error
}: QueryResult<
} = useQuery<
GetLaunchListTypes.GetLaunchList,
GetLaunchListTypes.GetLaunchListVariables
> = useQuery(GET_LAUNCHES);
>(GET_LAUNCHES);

if (loading) return <Loading />;
if (error) return <p>ERROR</p>;
Expand Down Expand Up @@ -120,10 +119,10 @@ const Launches: React.FC<LaunchesProps> = () => {
loading,
error,
fetchMore // highlight-line
}: QueryResult<
} = useQuery<
GetLaunchListTypes.GetLaunchList,
GetLaunchListTypes.GetLaunchListVariables
> = useQuery(GET_LAUNCHES);
>(GET_LAUNCHES);
// same as above
}
```
Expand Down Expand Up @@ -222,7 +221,6 @@ import gql from 'graphql-tag';
import { Loading, Header, LaunchDetail } from '../components'; // preserve-line
import { ActionButton } from '../containers'; // preserve-line
import { RouteComponentProps } from '@reach/router';
import { QueryResult } from '@apollo/react-common';
import * as LaunchDetailsTypes from './__generated__/LaunchDetails';

export const GET_LAUNCH_DETAILS = gql`
Expand Down Expand Up @@ -261,11 +259,10 @@ const Launch: React.FC<LaunchProps> = ({ launchId }) => {
data,
loading,
error
}: QueryResult<
} = useQuery<
LaunchDetailsTypes.LaunchDetails,
LaunchDetailsTypes.LaunchDetailsVariables
> = useQuery(
GET_LAUNCH_DETAILS,
>(GET_LAUNCH_DETAILS,
{ variables: { launchId } }
);

Expand Down

0 comments on commit d7ad7ba

Please sign in to comment.