Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Query in GraphQL returns argumentNotAccepted

Solved

Query in GraphQL returns argumentNotAccepted

Vacune
Shopify Partner
5 0 0

Hello,

I have the following query:

 

query MyQuery {
  priceList(id: "gid://shopify/PriceList/17287970890") {
    id
    prices(query: "variant_id:'40528948625482'", first: 1) {
      nodes {
        price {
          amount
          currencyCode
        }
        variant {
          id
        }
        compareAtPrice {
          amount
          currencyCode
        }
      }
    }
  }
}

In Shopify GraphiQL App gives me a correct result, without errors.

But by querying post from my application code it gives me the following error:

 

 

Field 'prices' doesn't accept argument 'query', locations - line - 4, column - 14, path - query MyQuery, priceList, prices, query, extensions - code - argumentNotAccepted, name - prices, typeName - Field, argumentName

 

According to the documentation, the prices connection has "query" as an argument and also from the Shopify GraphiQL App it works.

Does anyone know what could be happening?

 

thank you so much!

Accepted Solution (1)
ShopifyDevSup
Shopify Staff
1453 238 522

This is an accepted solution.

Hi @Vacune ,

 

The most likely cause of that error message would be making the API call with a version lower than 2024-01, as that's the version when the query filter got added to Pricelist.prices. This can be confirmed by adjusting the version number at the top left of the dev docs page for the object:

https://shopify.dev/docs/api/admin-graphql/2023-10/objects/PriceList#connection-prices 

 

Looking at the screenshot you provided of the 'Event Version' selector, that only applies to things like webhooks that are sent out and not to live API calls being made.

 

The version used for live API calls is determined by what version is specified in the URL when each API call is being made, here's the GraphQL Admin API endpoint docs which mention that:

https://shopify.dev/docs/api/admin-graphql#endpoints

 

When using a library it might not be clear what URL is being used for the API calls as the library handles it behind the scenes. However, we don't provide direct support for the libraries so you'd want to check the docs from wherever you got the library for how to specify which API version is being used for the calls.

 

This is important because API version changes occur every 3 months so it's recommended to keep up to date with the release notes and keep incrementing the API version called every quarter. 

 

Here's more info on API versioning in general and the release schedule, with the oldest served being a max of 1 year old:

https://shopify.dev/docs/api/usage/versioning 

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Replies 6 (6)

Eric-HAN
Shopify Partner
247 29 26

Hi, there 

 

You could check your api version usage of your code 

As far as i see

In version2024-01  2024-04 and above  it does has the query param

EricHAN_0-1718242763901.png

 

but in version 2023 version it does not have the param 

EricHAN_1-1718242878942.png

 

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee
Vacune
Shopify Partner
5 0 0

Thank you Eric for your answer, but that can't be the reason, since the app uses the latest stable version, 2024-04:

Vacune_0-1718254325389.png

 

Eric-HAN
Shopify Partner
247 29 26

Hi, Vacune

May i ask which app you using?

- Helpful? Please hit Like and mark it as a solution
Want to modify or custom changes on store? Let me help.
- Feel free to Email Me    Buy Me A Coffee
Vacune
Shopify Partner
5 0 0

Hi Eric,

 

I am using PHP Shopify SDK

ShopifyDevSup
Shopify Staff
1453 238 522

This is an accepted solution.

Hi @Vacune ,

 

The most likely cause of that error message would be making the API call with a version lower than 2024-01, as that's the version when the query filter got added to Pricelist.prices. This can be confirmed by adjusting the version number at the top left of the dev docs page for the object:

https://shopify.dev/docs/api/admin-graphql/2023-10/objects/PriceList#connection-prices 

 

Looking at the screenshot you provided of the 'Event Version' selector, that only applies to things like webhooks that are sent out and not to live API calls being made.

 

The version used for live API calls is determined by what version is specified in the URL when each API call is being made, here's the GraphQL Admin API endpoint docs which mention that:

https://shopify.dev/docs/api/admin-graphql#endpoints

 

When using a library it might not be clear what URL is being used for the API calls as the library handles it behind the scenes. However, we don't provide direct support for the libraries so you'd want to check the docs from wherever you got the library for how to specify which API version is being used for the calls.

 

This is important because API version changes occur every 3 months so it's recommended to keep up to date with the release notes and keep incrementing the API version called every quarter. 

 

Here's more info on API versioning in general and the release schedule, with the oldest served being a max of 1 year old:

https://shopify.dev/docs/api/usage/versioning 

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Vacune
Shopify Partner
5 0 0

thank you very very much!!!

I had not taken into account the call to the endpoint!! The post has helped me find the way to solve the problem.

Again, thank you very much!!