How to use fragments on the Query of bulkOperationRunQuery

Highlighted
New Member
3 0 0

I'm trying to write a bulk operation for orders and other operations, I use fragments to write more DRY but i can't figured how to use fragments on the query from . 

bulkOperationRunQuery.
on normal query it works fine. here my code.
 
const orderNodes  = gql`
  fragment orderNodes on Order {
    id
    name
    createdAt
    cancelledAt
  }
`;
   const bulkOrders = await client.mutate({
      mutation: gql`
        mutation {
          bulkOperationRunQuery(
            query"""
              query {
                 orders {
                    edges {
                       node {
                           ...orderNodes 
                       }
                   }
               }
           }
           ${orderNodes }
         """
      ) {
           bulkOperation {
              id
              status
            }
            userErrors {
              field
              message
            }
          }
        }
      `,
    });
 
the response: 
 
data: {
bulkOperationRunQuery: {
bulkOperation: null,
userErrors: [
{
field: [ 'query', [length]: 1 ],
message: 'Invalid bulk query: Fragment ordersNodes was used, but not defined',
__typename: 'UserError'
},
{
field: [ 'query', [length]: 1 ],
message: 'Invalid bulk query: Fragment orderNodes was defined, but not used',
__typename: 'UserError'
},
[length]: 2
],
__typename: 'BulkOperationRunQueryPayload'
}
},
extensions: {
cost: {
requestedQueryCost: 10,
actualQueryCost: 10,
throttleStatus: {
maximumAvailable: 1000,
currentlyAvailable: 978,
restoreRate: 50
}
}
}
 
Please help.
 
 
0 Likes