Example #1
0
 resolve: ({ options }) => {
   const { tag_id } = options
   if (tag_id) {
     return gravity(`tag/${tag_id}`).then(tag => assign({ context_type: "Tag" }, tag))
   }
   return null
 },
Example #2
0
 related_artists: ({ params }) => {
   return gravity("filter/artworks", {
     artist_id: params.related_artist_id,
     for_sale: true,
     size: RESULTS_SIZE,
   }).then(({ hits }) => hits)
 },
Example #3
0
        resolve: ({ id }, options) => {
          if (options.all) {
            return gravity.all(`sale/${id}/sale_artworks`, options)
          }

          return gravity(`sale/${id}/sale_artworks`, options)
        },
Example #4
0
export const artworkLayers = id =>
  gravity(`related/layers`, { artwork: [id] })
    .then(layers => enhance(layers, { artwork_id: id }))
    .then(layers =>
      // Move fair layer to the beginning
      remove(layers, ({ type }) => type === "fair").concat(layers)
    )
Example #5
0
 resolve: (root, { id }) => {
   return gravity(`show/${id}`).then(show => {
     if (!show.displayable) {
       return new HTTPError("Show Not Found", 404)
     }
     return show
   })
 },
Example #6
0
 resolve: ({ id }, options) => {
   return gravity(`artists/trending`, {
     gene: id,
   }).then(artists => {
     if (_.has(options, "sample")) return _.take(_.shuffle(artists), options.sample)
     return artists
   })
 },
Example #7
0
 resolve: ({ id, sale_ids }) => {
   if (sale_ids && sale_ids.length > 0) {
     const sale_id = _.first(sale_ids)
     // don't error if the sale/artwork is unpublished
     return gravity(`sale/${sale_id}/sale_artwork/${id}`).catch(() => null)
   }
   return null
 },
Example #8
0
 resolve: ({ id, item_type }) => {
   return gravity(`set/${id}/items`).then(items => {
     return items.map(item => {
       item.item_type = item_type // eslint-disable-line no-param-reassign
       return item
     })
   })
 },
Example #9
0
 resolve: ({ aggregations }) => {
   if (!isExisty(aggregations.merchandisable_artists)) {
     return null
   }
   return gravity(`artists`, {
     ids: keys(aggregations.merchandisable_artists),
   })
 },
Example #10
0
 resolve: searchResult => {
   const id = parseId(searchResult)
   const type = parseOgType(searchResult)
   return gravity(routing(type, id).api).then(response => {
     response.type = type // eslint-disable-line no-param-reassign
     return response
   })
 },
Example #11
0
export const geneArtworks = (id, size) => {
  return gravity("filter/artworks", {
    gene_id: id,
    for_sale: true,
    size: 60,
  }).then(({ hits }) => {
    return slice(shuffle(hits), 0, size)
  })
}
Example #12
0
 return featuredAuction().then(auction => {
   if (auction) {
     return gravity(`sale/${auction.id}/sale_artworks`, {
       size: RESULTS_SIZE,
     }).then(sale_artworks => {
       return map(sale_artworks, "artwork")
     })
   }
 })
Example #13
0
export const featuredAuction = () => {
  return gravity("sales", {
    live: true,
    size: 1,
    sort: "timely_at,name",
  }).then(sales => {
    if (sales.length) {
      return first(sales)
    }
  })
}
Example #14
0
 return featuredFair().then(fair => {
   if (fair) {
     return gravity("filter/artworks", {
       fair_id: fair.id,
       for_sale: true,
       size: 60,
     }).then(({ hits }) => {
       return slice(shuffle(hits), 0, RESULTS_SIZE)
     })
   }
 })
Example #15
0
      resolve: ({ id, partner, image_versions, image_url }) => {
        if (image_versions && image_versions.length && image_url) {
          return Image.resolve({ image_versions, image_url })
        }

        return gravity(`partner/${partner.id}/show/${id}/artworks`, {
          published: true,
        }).then(artworks => {
          Image.resolve(getDefault(find(artworks, { can_share_image: true })))
        })
      },
Example #16
0
 resolve: (root, options) => {
   let gravityOptions = options
   if (options.near) {
     gravityOptions = _.assign(options, {
       // eslint-disable-line no-param-reassign
       near: `${options.near.lat},${options.near.lng}`,
       max_distance: options.near.max_distance,
     })
   }
   return gravity("shows", gravityOptions)
 },
Example #17
0
 resolve: ({ id, counts }, options) => {
   const parsedOptions = _.omit(parseRelayOptions(options), "page")
   const gravityOptions = _.extend(parsedOptions, {
     exclude_artists_without_artworks: true,
   })
   return gravity(`gene/${id}/artists`, gravityOptions).then(response => {
     return connectionFromArraySlice(response, options, {
       arrayLength: counts.artists,
       sliceStart: gravityOptions.offset,
     })
   })
 },
Example #18
0
  resolve: (_root, { id }, _request, { fieldNodes }) => {
    // If you are just making an artworks call ( e.g. if paginating )
    // do not make a Gravity call for the gene data.
    const blacklistedFields = ["filtered_artworks", "id", "__id"]
    if (queriedForFieldsOtherThanBlacklisted(fieldNodes, blacklistedFields)) {
      return gravity(`gene/${id}`)
    }

    // The family and browsable are here so that the type system's `isTypeOf`
    // resolves correctly when we're skipping gravity data
    return { id, published: null, browseable: null }
  },
Example #19
0
      resolve: (show, options) => {
        const path = `partner/${show.partner.id}/show/${show.id}/artworks`

        let fetch = null

        if (options.all) {
          fetch = gravity.all(path, options)
        } else {
          fetch = gravity(path, options)
        }

        return fetch.then(exclude(options.exclude, "id"))
      },
Example #20
0
export const featuredFair = () => {
  return gravity("fairs", {
    size: 5,
    active: true,
    has_homepage_section: true,
  }).then(fairs => {
    if (fairs.length) {
      return first(
        sortBy(fairs, ({ banner_size }) => ["x-large", "large", "medium", "small", "x-small"].indexOf(banner_size))
      )
    }
  })
}
Example #21
0
        resolve: ({ id }, options) => {
          const invert = saleArtworks => map(saleArtworks, "artwork")

          if (options.all) {
            return gravity
              .all(`sale/${id}/sale_artworks`, options)
              .then(invert)
              .then(exclude(options.exclude, "id"))
          }

          return gravity(`sale/${id}/sale_artworks`, options)
            .then(invert)
            .then(exclude(options.exclude, "id"))
        },
Example #22
0
      resolve: ({ id, partner, image_versions, image_url }) => {
        if (image_versions && image_versions.length && image_url) {
          return Image.resolve({ image_versions, image_url })
        }

        return (
          partner &&
          gravity(`partner/${partner.id}/show/${id}/artworks`, {
            size: 1,
            published: true,
          }).then(artworks => {
            const artwork = artworks[0]
            return artwork && Image.resolve(getDefault(artwork.images))
          })
        )
      },
Example #23
0
 return gravity(`sale/${sale_id}`).then(sale => {
   return gravity("increments", {
     key: sale.increment_strategy,
   }).then(incrs => {
     // We already have the asking price for the lot. Produce a list
     // of increments beyond that amount.
     const tiers = incrs[0].increments
     const increments = [minimum_next_bid_cents]
     const limit = BIDDER_POSITION_MAX_BID_AMOUNT_CENTS_LIMIT || Number.MAX_SAFE_INTEGER
     let current = 0 // Always start from zero, so that all prices are on-increment
     while (increments.length < 100 && current <= limit) {
       if (current > minimum_next_bid_cents) increments.push(current)
       const { to, amount: increase } = tiers[0]
       current += increase
       if (current > to && tiers.length > 1) tiers.shift()
     }
     return increments
   })
 })
 resolve: (root, { key, id, followed_artist_id, related_artist_id }) => {
   // TODO Really not entirely sure what this `display` param is about.
   const display = true
   switch (key) {
     case "generic_gene":
       return { key, display, params: find(genericGenes, ["id", id]) }
     case "genes":
       return gravity(`gene/${id}`).then(gene => {
         return { key, display, params: { id, gene } }
       })
     case "followed_artist":
       return { key, display, params: { followed_artist_id } }
     case "related_artists":
       return {
         key,
         display,
         params: { followed_artist_id, related_artist_id },
       }
     default:
       return { key, display, params: {} }
   }
 },
Example #25
0
 resolve: (root, { id }) => {
   return gravity(`sale_artwork/${id}`)
 },
Example #26
0
 resolve: (root, { id }) => gravity(`set/${id}`),
Example #27
0
 resolve: (root, { id }) => gravity(`sale/${id}`),
Example #28
0
 resolve: (sale, { id }) => gravity(`sale/${sale.id}/sale_artwork/${id}`),
Example #29
0
 resolve: sale => gravity(`increments`, { key: sale.increment_strategy }).then(incs => incs[0].increments),
Example #30
0
 resolve: ({ associated_sale }) => {
   if (associated_sale && associated_sale.id) {
     return gravity(`sale/${associated_sale.id}`)
   }
   return null
 },