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.

Error - No effect of the 'first' argument in bulk operations GraphQL mutation query.

Solved

Error - No effect of the 'first' argument in bulk operations GraphQL mutation query.

RavindraPatel
Shopify Partner
31 1 5

Using 'first' argument in a bulk query i am trying to get 1000 customers out of 500000 and i'm getting all 500000 customers. Is there a reason for this?
How can i get different JSONL files each contains 1000 customers?

The reason for taking 1000 customers is that if 500000 customers are found in one file then the file size becomes bigger and it becomes difficult to read.

Here is my query:

mutation {
    bulkOperationRunQuery(
        query:"""
        {
            customers(first:1000) {
               edges {
                   node {
                       id
                       firstName
                       lastName
                       email
                  }
               }
           }
       }
       """
      )
     {
      bulkOperation {
           id
           status
      }
      userErrors {
          field
          message
      }
  }
}

 

Shopify reference:
https://shopify.dev/tutorials/perform-bulk-operations-with-admin-api#write-a-bulk-operation
https://shopify.dev/docs/admin-api/graphql/reference/bulk-operations/bulkoperation

Accepted Solution (1)
Gregarican
Shopify Partner
1033 86 292

This is an accepted solution.

Try substituting created_at with customer_date and it works based on my testing. Also mentioned here --> https://community.shopify.com/c/Shopify-APIs-SDKs/Graphql-query-for-customers-with-date-filter-not-f...

 

Hope this helps!

View solution in original post

Replies 6 (6)

Kevin_A
Shopify Staff
318 42 61

Hey @RavindraPatel 

In the documentation you linked, I wanted to point out it mentions that first is ignored:

The first argument is optional and ignored if present, so it can be removed.

 

If you want to reduce the sample size, I would suggest filtering on something else, perhaps created_at?

Kevin_A | Solutions Engineer @ Shopify 
 - Was my reply helpful? Click Like to let me 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

RavindraPatel
Shopify Partner
31 1 5

Hey @Kevin_A

For bulk customer query the 'created_at' filter does not work. It returns all customers.. 

It works for products and orders.

Gregarican
Shopify Partner
1033 86 292

This is an accepted solution.

Try substituting created_at with customer_date and it works based on my testing. Also mentioned here --> https://community.shopify.com/c/Shopify-APIs-SDKs/Graphql-query-for-customers-with-date-filter-not-f...

 

Hope this helps!

RavindraPatel
Shopify Partner
31 1 5

Thank you guys.

 
sachin_kerala
Visitor
3 0 0

Can someone help how to retrieve line items only using Bulk graphql , 

Below query is showing the error ('userErrors : ', [{u'field': [u'query'], u'message': u"The parent 'node' field for a nested connection must select the 'id' field. Connection fields without 'id': orders."}]). Please advise whether we can retrieve only line items using bulk graphql ?

mutation {
bulkOperationRunQuery(query: """
{
orders {
edges {
node {
lineItems {
edges {
node {
id
}
}
}

}
}
}
}
""") {
bulkOperation {
id
status
}
userErrors {
field
message
}
}
}

Gregarican
Shopify Partner
1033 86 292

If you re-read the thread above, I believe the way that GQL operates requires at least an id field be present for any edges.node scenario. Personally I would rather have a little "too much" data, as compared to not enough. It's easier to discard any fields that you don't want than make additional calls or jump through another hoop if you need other fields, right?