Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. export default createPaginationContainer(
  3.   ProductsList,
  4.   {
  5.     products: graphql`
  6.       fragment ProductsList_products on Products
  7.       @argumentDefinitions(
  8.         count: { type: "Int", defaultValue: 10 }
  9.         cursor: { type: "ID" }
  10.       ) {
  11.           products(
  12.               first: $count
  13.               after: $cursor
  14.           ) @connection(key: "Product_product") {
  15.               edges {
  16.                   node {
  17.                       id
  18.                       ...Product_product
  19.                   }
  20.               }
  21.               pageInfo {
  22.                   startCursor
  23.                   endCursor
  24.               }
  25.           }
  26.       }
  27.     `
  28.   },
  29.   {
  30.     direction: 'forward',
  31.     getConnectionFromProps(props) {
  32.       return props.products;
  33.     },
  34.     getFragmentVariables(prevVars, totalCount) {
  35.       return {
  36.         ...prevVars,
  37.         count: totalCount,
  38.       };
  39.     },
  40.     getVariables(props, {count, cursor}, fragmentVariables) {
  41.       return {
  42.         count,
  43.         cursor,
  44.       };
  45.     },
  46.     query: graphql`
  47.       query ProductsListQuery {
  48.         products(
  49.             first: $count
  50.             after: $cursor
  51.         ) {
  52.           edges {
  53.             node {
  54.               id
  55.               ...Product_product
  56.             }
  57.           }
  58.           pageInfo {
  59.             startCursor
  60.             endCursor
  61.           }
  62.         }
  63.       }
  64.     `
  65.   }
  66. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement