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

Theme Rest Resource doesn't have fromData applied automatically #1086

Open
4 tasks done
david-w-shopify opened this issue Jun 21, 2024 · 4 comments
Open
4 tasks done

Comments

@david-w-shopify
Copy link

Issue summary

Before opening this issue, I have:

  • Upgraded to the latest version of the relevant packages
    • @shopify/shopify-api package and version: 11.0.1
    • @shopify/shopify-app-remix package and version: 3.0.1
    • Node version: 21.7.1
    • Operating system: macOS Sonoma 14.5
  • Found a reliable way to reproduce the problem that indicates it's a problem with the package
  • Looked for similar issues in this repository
  • Checked that this isn't an issue with a Shopify API

Theme rest resource no longer has fromData applied to it. I suspect this is happening with other rest resources too, but it's only impacted me with themes.

Using this snippet

const { admin, session } =  await authenticate.admin(request);
const theme = new admin.rest.resources.Theme({
  session,
  fromData: {
    name: 'Test',
    src: 'test',
    role: 'unpublished'
  }
});

console.log({ theme })

Expected behavior

Using the above snippet I'd expect this to be logged:

{
    theme: Theme {
    name: 'Test',
    src: 'test',
    role: 'unpublished',
    created_at: undefined,
    id: undefined,
    previewable: undefined,
    processing: undefined,
    theme_store_id: undefined,
    updated_at: undefined
  }
}

Actual behavior

I get this

{
    theme: Theme {
    name: undefined,
    src: undefined,
    role: undefined,
    created_at: undefined,
    id: undefined,
    previewable: undefined,
    processing: undefined,
    theme_store_id: undefined,
    updated_at: undefined
  }
}

Steps to reproduce the problem

I've created this repo to reproduce the issue: https://github.com/david-w-shopify/shopify-rest-resource-issue.

  1. Clone the above repo and install dependencies (if you'd rather set it up yourself, just create a new remix app via the cli) and copy from app/routes/app.tsx the reproduction repo
  2. Run pnpm dev and install the app on a test store
  3. Visit the app in your store
  4. Check the console to see the theme variable being logged
@matthew-charles-chan
Copy link

I have found the same behaviour with Orders.

Using this snippet:

  const { admin, session } = await authenticate.admin(request);

  const orderData = {
    email: "[email protected]",
    fulfillment_status: "fulfilled",
    fulfillments: [
      {
        location_id: 24826418,
      },
    ],
    line_items: [
      {
        variant_id: 447654529,
        quantity: 1,
      },
    ],
  };

  const order = new admin.rest.resources.Order({
    session,
    fromData: orderData,
  });

  await order.save({ update: true });
  

Expected Behaviour

A new order will be created without error.

Actual Behaviour

A 400 error is thrown:

errors: { order: 'Required parameter missing or invalid' }

@matteodepalo
Copy link
Contributor

Thank you for reporting this @david-w-shopify, we'll take a look.

Copy link
Contributor

github-actions bot commented Sep 2, 2024

We're labeling this issue as stale because there hasn't been any activity on it for 60 days. While the issue will stay open and we hope to resolve it, this helps us prioritize community requests.

You can add a comment to remove the label if it's still relevant, and we can re-evaluate it.

@NirvanaNrv
Copy link

I got the same thing with Webhook. Logging in the constructor of Base showed me a correctly updated 'this' from 'fromData' right before exiting. Commenting the field block at the end of webhook.mjs made it work properly. And that is the length of my analysis on this. Note fromData was working for me a few months ago.

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

No branches or pull requests

4 participants