Skip to content
This repository has been archived by the owner on Jul 14, 2022. It is now read-only.

Update GraphQL queries #567

Merged
merged 6 commits into from
Jan 14, 2020
Merged

Update GraphQL queries #567

merged 6 commits into from
Jan 14, 2020

Conversation

orzechdev
Copy link
Contributor

I want to merge this change because current storefront doesn't work with the latest API, what this PR should fix.

Screenshots

Pull Request Checklist

  1. All visible strings are translated with proper context.
  2. All data-formatting is locale-aware (dates, numbers, and so on).
  3. The changes are tested.
  4. The code is documented (docstrings, project documentation).
  5. Changes are mentioned in the changelog.

@orzechdev orzechdev self-assigned this Jan 13, 2020
@netlify
Copy link

netlify bot commented Jan 13, 2020

Deploy preview for saleor-storefront-stage processing.

Building with commit 9c43ae0

https://app.netlify.com/sites/saleor-storefront-stage/deploys/5e1daf6f979a1300076425f6

@@ -55,7 +55,7 @@ export const productListDetails = gql`
edges {
node {
...BasicProductFields
price {
basePrice {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field requires a staff permission - which means it's meant for the dashboard app. I know it's kind of messed up together - we need to have separate API for storefront and dashboard.

Public pricing should be taken from the pricing field.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The product's price is a range since we can override the price for one of its variants. To get this range we can use:

pricing {
  priceRange {
    start {
      net {
        amount
      }
    }
    stop {
      net {
        amount
      }
    }
  }
}

Example response:

"pricing": {
  "priceRange": {
    "start": {
      "net": {
        "amount": 1.8
      }
    },
    "stop": {
      "net": {
        "amount": 4.2
      }
    }
  }
}

In this case, in the product page, we should render the price as "From $1.8". If the amounts were equal then we could render the precise value. That's the logic we used to have in the old storefront in the good old Django-templates times ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed it with rendering range e.g. "1,80 USD - 4,20 USD" if values are not equal, similarly as it is rendered when variants exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I used gross value... Does it matter?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's fine to use gross prices for now. Eventually, it should depend on this setting:

{
  shop {
    displayGrossPrices
  }
}

But it can be done in a separate PR (we have an issue for that)

@orzechdev orzechdev marked this pull request as ready for review January 14, 2020 11:32
@maarcingebala maarcingebala merged commit e52d727 into master Jan 14, 2020
@maarcingebala maarcingebala deleted the fix/graphql-api-update branch January 14, 2020 12:55
@domantasjurkus
Copy link

A new stable release with this fix has note been drafted - following the README of saleor-storefront, running the 0.7.0 version throws the same 400 bad requests. Could you draft a new release?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants