Skip to content

Instantly share code, notes, and snippets.

@danReynolds
Created February 20, 2020 22:12
Show Gist options
  • Save danReynolds/4722e54f72f88e6d6fa86a7488c226dc to your computer and use it in GitHub Desktop.
Save danReynolds/4722e54f72f88e6d6fa86a7488c226dc to your computer and use it in GitHub Desktop.
Shopify meetup notes
# Types for Query Hooks:
Custom TS typings for GraphQL queries in `.graphql` files:
https://github.com/Shopify/graphql-tools-web/tree/master/packages/graphql-typescript-definitions
Benefit is that you get more robust typing of query usages, as well as automatic type inferencing vs explicit specification for `useQuery`, `useMutation` using their hooks extensions: https://github.com/Shopify/quilt/tree/master/packages/react-graphql. Adds some additional hooks like `createAsyncQuery` for a lazy-loaded query document.
Chose to use `.graphql` files not co-located with components.
# Dynamic fixtures
https://github.com/Shopify/graphql-tools-web/tree/master/packages/graphql-fixtures
More robust fixture library that generates objects based off your schema and a passed in query. Offers type-aware safety for the fixtures, and allows them to expand automatically when new fields are added or be overridden easily for customized field values.
Was used because fixture files did not scale well across different testing use cases, one test might want a certain edge case, another might want another, so they make two fixtures and need to maintain both or combine both into one and make it brittle.
# Smaller graphql query documents
The code generated for graphql-tag documents was very large and doing things at runtime that were unnecessary. https://github.com/Shopify/graphql-tools-web/tree/master/packages/graphql-mini-transforms is a webpack loader for minifying graphql documents to reduce output size and runtime operations. Additionally generates document identifiers for things like persisted queries.
# Asked about cache invalidation
They also were looking for more cache invalidation solutions, are writing their own cache in the future but currently use vanilla Apollo's. Use tombstones and replicated data stores to keep different platforms in sync.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment