Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Stock query returns null despite being present in the database #15738

Open
supersilverlemonhaze opened this issue Apr 1, 2024 · 5 comments

Comments

@supersilverlemonhaze
Copy link

supersilverlemonhaze commented Apr 1, 2024

What are you trying to achieve?

I am simply trying to get the stocks of a warehouse ...
Looking at the API reference and code it's supposed to be possible.

Steps to reproduce the problem

Starting from a point of a preconfigured saleor instance containing example products etc.:

Run stocks Query to validate existing stocks:

query getStocks {
  stocks(first: 10) {
    edges {
      node {
        id
        quantity
        warehouse {
          id
        }
      }
    }
  }
}

Take any warehouse ID for some stock with a high quantity and run the stock Query:

query getStocks($warehouseID: ID!) {
  stock(id: $warehouseID) {
    warehouse {
      id
    }
  }
}

Output:

{
  "data": {
    "stock": null
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 1,
      "maximumAvailable": 50000
    }
  }
}

What did you expect to happen?

In the first step I verify that the warehouse contains stock. Using that same warehouse ID in the stock query is logically supposed to give me the stocks of the warehouse.

Also: The APIs documentation is horrible! Look at the docs of the stock query:

Look up a stock by ID

Requires one of the following permissions: MANAGE_PRODUCTS.
Type
Stock
Arguments
id: ID!
ID of a(n) warehouse

'Look up a stock by ID' One might think its own ID, but its the warehouse ID Be a bit more professional please. Fighting such this horrible docs has cost me already days of work. The product is so immature I'm really thinking of switching to something else. Please fix this, querying the stock is the bare minimum an ecommerce backend should be able to allow.

Logs

No response

Environment

Saleor version: ghcr.io/saleor/saleor:3.19

@teddyondieki
Copy link
Contributor

I can help with this by:

  1. Updating the documentation to fix the said discrepancy
  2. Add a stocks field to the warehouse type to allow the fetching of stocks related to a particular warehouse

@supersilverlemonhaze
Copy link
Author

I can help with this by:

  1. Updating the documentation to fix the said discrepancy
  2. Add a stocks field to the warehouse type to allow the fetching of stocks related to a particular warehouse

Also not just stocks type in warehouse (which is a good idea), but also please make the stock query work in standalone and specified in docs
Thanks

@teddyondieki
Copy link
Contributor

I can help with this by:

  1. Updating the documentation to fix the said discrepancy
  2. Add a stocks field to the warehouse type to allow the fetching of stocks related to a particular warehouse

Also not just stocks type in warehouse (which is a good idea), but also please make the stock query work in standalone and specified in docs Thanks

I was able to fetch a single stock using it's id (not a warehouse ID which seems to be a mistake in the docs):

Screenshot 2024-04-06 at 12 03 19

@supersilverlemonhaze
Copy link
Author

supersilverlemonhaze commented Apr 6, 2024 via email

@teddyondieki
Copy link
Contributor

@korycins mind reviewing this?

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

No branches or pull requests

2 participants