KeenDev
9/27/2018 - 7:50 AM

Storefront API

{
  customer(customerAccessToken: "17b27e61eddfa83f1d755a6a9cf5180d") { (:Taken from customerAccessToken.accessToken:)
    orders(first: 5) {
			pageInfo{
				hasNextPage
			}
      edges {
				cursor 
        node {
          lineItems(first: 1) {
            edges {
              node {
                quantity
                title
								variant{
									id
									price
									image {
										transformedSrc
										altText
									}
                }
              }
            }
          }
        }
      }
    }
  }
}

(:
Sample products:
- A
  - wings: 4
- B
  - party: 2
  - fries: 3
- C
  - rib: 1
  - twin: 1
- D
  - nachos: 1
  - carnitas: 1
  - salad: 1
  - fogo fried chick: 1
- E
  - chicken rack: 1
  - jjampong soup: 1
  - glazed chicken fries: 1
- F
  - chicken steak: 1
  - rib: 1
  
  order arguments:
  first: Returns up to the first n elements from the list.
  last: Returns up to the last n elements from the list.
  
  sample query:
    order(first: 3)
    lineItems(first: 20) //assume max of 20 will return all items
    
  return: 
    - order A:
      - all items
    - order B:
      - all items
    - order C:
      - all items
    - and current cursor: order A
    
  response visualization:
    orders |[A] B C| D E F  
    [] - current cursor/page
    | | - array of orders returned
    
  next sample query:
    order(first: 2, after: current_cursor) current_cursor is at A
    
   return: 
    - order B:
      - all items
    - order C:
      - all items
    - and current_cursor: order B
    
  response visualization:
    orders A |[B] C| D E F
    
  next sample query:
    order(first: 3, after: current_cursor) current_cursor is at B
  
 return: 
  - order C:
    - all items
  - order D:
    - all items
  - order E:
    - all items
  - and current_cursor: order C
    
  response visualization:
    orders A B |[C] D E| F
    
  next sample query:
    order(last: 2, before: current_cursor) current_cursor is at C
  
 return: 
  - order B:
    - all items
  - order C:
    - all items
  - and current_cursor: order F
    
  response visualization:
    orders |[A] B| C D E F

  
mutation customerAccessTokenCreate($input: CustomerAccessTokenCreateInput!) {
  customerAccessTokenCreate(input: $input) {
    customerAccessToken {
      accessToken 
      expiresAt
    }
    customerUserErrors {
      field
      message
    }
  }
}