Hi,
I am new to GraphQL and I am wondering how to “import orders to ShipHero” using this new API. First I wanted to use REST API which I am familiar with, but after seeing a deprecation notice and recommendation Legacy API Deprecation it looks like only longterm sustainable option is using the GraphQL API.
I am following the documentations and found out that the example you provide is not working for me. I am getting error "Product with sku
testSKU12345 does not exist"
, so I have following questions:
- How to list existing products to know which SKU-s are valid and which not?
- How to create product if the product does not exist and reuse the product if product with same SKU is already in the system, so the order will be always successfully imported (all in a single call preferably)?
Example taken from: Examples-mutation – Developer Resources | ShipHero
The exact call I used:
mutation {
order_create(
data: {
order_number: "11223345"
shop_name: "ExampleShop"
fulfillment_status: "pending"
order_date: "2019-07-29"
total_tax: "29.00"
subtotal: "150.00"
total_discounts: "20.00"
total_price: "159.00"
shipping_lines: {
title: "UPS"
price: "0.00"
carrier: "UPS"
method: "Ground"
}
shipping_address: {
first_name: "John"
last_name: "Johnson"
company: "The Johnson Co"
address1: "2543 Duck St."
address2: "Apt. 2"
city: "Oklahoma"
state: "Oklahoma"
state_code: "OK"
zip: "73008"
country: "US"
country_code: "US"
email: "johnjohnsonco@johnsonco.com"
phone: "5555555555"
}
billing_address: {
first_name: "John"
last_name: "Johnson"
company: "The Johnson Co"
address1: "2543 Duck St."
address2: "Apt. 2"
city: "Oklahoma"
state: "OK"
state_code: "OK"
zip: "73008"
country: "US"
country_code: "US"
email: "johnjohnsonco@johnsonco.com"
phone: "5555555555"
}
line_items: {
sku: "testSKU12345"
partner_line_item_id: "282960815"
quantity: 2
price: "150.00"
product_name: "Example Product"
fulfillment_status: "pending"
quantity_pending_fulfillment: 2
# warehouse_id: "V2FyZWhvdYNlOjgwNzU="
}
required_ship_date: "2019-08-29"
}
) {
request_id
complexity
order {
id
order_number
shop_name
fulfillment_status
order_date
total_tax
subtotal
total_discounts
total_price
custom_invoice_url
account_id
email
profile
packing_note
required_ship_date
shipping_address {
first_name
last_name
company
address1
address2
city
state
state_code
zip
country
country_code
email
phone
}
line_items(first: 1) {
edges {
node {
id
sku
product_id
quantity
product_name
fulfillment_status
quantity_pending_fulfillment
quantity_allocated
backorder_quantity
eligible_for_return
customs_value
warehouse_id
locked_to_warehouse_id
}
}
}
}
}
}
response:
{
"errors": [
{
"message": "Product with sku `testSKU12345` does not exist",
"operation": "order_create",
"field": "order_create",
"request_id": "60475330c3b38731e897bb0b",
"code": 5
}
],
"data": {
"order_create": null
}
}
Thanks for respone!