Shopify / shopify-app-bridge

https://shopify.dev/docs/api/app-bridge
89 stars 9 forks source link

Can Direct API access be used for the REST API? #414

Open zeyios opened 3 months ago

zeyios commented 3 months ago

In my app, I've successfully used Direct API access with the GraphQL API like this:

const response = await fetch(
  `shopify:admin/api/${API_VERSION}/graphql.json`,
  {
    method: 'POST',
    body: JSON.stringify({ query, variables }),
  }
);

However, when I try to use the same approach for the REST API, it doesn’t work:

const result = await fetch(
  `shopify:admin/api/${API_VERSION}/themes.json`,
  {}
);

console.log('result', result);

I get the following error: Fetch API cannot load shopify:admin/api/2024-07/themes.json. URL scheme "shopify" is not supported.

darrynten commented 3 months ago

I don't think that will ever be possible, it also seems like rest will eventually be entirely replaced with graph over time so transition your calls to graph as you move them over to the new direct api.

The themes endpoints just arrived in unstable

waleedarshad commented 2 months ago

@darrynten It is mentioned in their offical documentation. https://shopify.dev/docs/api/app-bridge-library#direct-api-access

but not working. Is the docs outdated?

darrynten commented 2 months ago

Is embedded_app_direct_api_access enabled in your app toml file?