diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-02-02 15:23:20 -0500 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-02-02 15:23:20 -0500 |
| commit | eabff7cd396d1f37ceb929e666f082ce57f07919 (patch) | |
| tree | 6fbd487688ee9e53bada734288994c35b732150e /frontend/queries | |
| parent | cd0b07b3adb36fb5ec098f9e511ab45d774fee7b (diff) | |
updateS
Diffstat (limited to 'frontend/queries')
| -rw-r--r-- | frontend/queries/fragments.js | 6 | ||||
| -rw-r--r-- | frontend/queries/index.js | 71 |
2 files changed, 45 insertions, 32 deletions
diff --git a/frontend/queries/fragments.js b/frontend/queries/fragments.js index 019992e..1708d78 100644 --- a/frontend/queries/fragments.js +++ b/frontend/queries/fragments.js @@ -5,12 +5,6 @@ export const itemDetails = gql` id title price - fullPrice description - image { - id - url - secret - } } `; diff --git a/frontend/queries/index.js b/frontend/queries/index.js index 8b7897f..fb7445e 100644 --- a/frontend/queries/index.js +++ b/frontend/queries/index.js @@ -1,23 +1,26 @@ -import gql from 'graphql-tag'; -import { itemDetails } from './fragments'; +import gql from "graphql-tag"; +import { itemDetails } from "./fragments"; export const CREATE_ITEM_MUTATION = gql` ${itemDetails} - mutation CreateLinkMutation($description: String!, $title: String!, $imageId: ID, $price: Int!) { - createItem( - description: $description, - title: $title, - imageId: $imageId - price: $price - ) { + mutation createItem($description: String!, $title: String!, $price: Int!) { + createItem(description: $description, title: $title, price: $price) { ...itemDetails } } `; export const CREATE_USER_MUTATION = gql` - mutation CreateUserMutation($email: String!, $name: String!, $idToken: String!) { - createUser(email: $email, name: $name, authProvider: { auth0: { idToken: $idToken } }) { + mutation CreateUserMutation( + $email: String! + $name: String! + $idToken: String! + ) { + createUser( + email: $email + name: $name + authProvider: { auth0: { idToken: $idToken } } + ) { id email name @@ -52,11 +55,19 @@ export const CREATE_ORDER_MUTATION = gql` export const ALL_ITEMS_QUERY = gql` # Import the Fragment ${itemDetails} - query AllLinksQuery($skip: Int = 0, $first: Int = 3) { - _allItemsMeta { - count + query AllItemsQuery($skip: Int = 0, $first: Int = 3) { + itemsConnection(orderBy: createdAt_DESC, first: $first, skip: $skip) { + pageInfo { + hasNextPage + hasPreviousPage + startCursor + endCursor + } + aggregate { + count + } } - allItems(orderBy: createdAt_DESC, first: $first, skip: $skip) { + items(orderBy: createdAt_DESC, first: $first, skip: $skip) { ...itemDetails } } @@ -74,12 +85,14 @@ export const SINGLE_ITEM_QUERY = gql` export const SEARCH_ITEMS_QUERY = gql` ${itemDetails} query SearchItems($searchTerm: String!) { - allItems(filter:{ - OR:[ - { title_contains: $searchTerm }, - { description_contains: $searchTerm }, - ] - }) { + allItems( + filter: { + OR: [ + { title_contains: $searchTerm } + { description_contains: $searchTerm } + ] + } + ) { ...itemDetails } } @@ -97,12 +110,18 @@ export const DELETE_ITEM_MUTATION = gql` export const UPDATE_LINK_MUTATION = gql` ${itemDetails} - mutation UpdateItem($id: ID!, $title: String!, $description: String!, $price: Int!, $fullPrice: Int!) { + mutation UpdateItem( + $id: ID! + $title: String! + $description: String! + $price: Int! + $fullPrice: Int! + ) { updateItem( - id: $id, - description: $description, - title: $title, - price: $price, + id: $id + description: $description + title: $title + price: $price fullPrice: $fullPrice ) { ...itemDetails |
