Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
How to make requests to Shopify's GraphQL Admin API with Vue & Apollo

I'm struggling to make requests to Shopify's GraphQL Admin API from my Vue app with the following setup:

src/lib/apolloClient.js

import { ApolloClient, createHttpLink, InMemoryCache } from "@apollo/client";

const httpLink = createHttpLink({
  uri: "https://{shop}.myshopify.com/admin/api/2021-07/graphql.json",
});

const cache = new InMemoryCache();

const apolloClient = new ApolloClient({
  link: httpLink,
  headers: {
    "X-Shopify-Access-Token": "{password}",
  },
  cache,
});

export default apolloClient;

src/main.js

import { createApp, provide, h } from "vue";
import "tailwindcss/tailwind.css"
import App from "./App.vue";
import apolloClient from "./lib/apolloClient";

createApp({
  setup() {
    provide(DefaultApolloClient, apolloClient);
  },
  render: () => h(App),
}).mount("#app");

I've been getting a CORS preflight error

No 'Access-Control-Allow-Origin' header is present on the requested resource

And when adding

fetchOptions: {
  mode: 'no-cors'
}

to my ApolloClient initialisation I get the following error:

unexpected end of JSON

I'm not too sure if my setup is completely not ideal or if I'm just missing a few configs.

I'm very new to Shopify Dev, but I'd like to build some extended functionality into my product listing pages with JavaScript. If anyone has got some experience with this, I'd appreciate some advice on how I should be architecting this, I'm not at all opposed to taking a completely different approach.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

That's by design, you aren't supposed to hit the Admin API on the front-end due to the security reasons, mainly due to the fact that you'd need to embed auth keys in your front-end bundle and that's always prone to disastrous effects.

You'll need to route those requests to a backend app of your own and that'll consume the API and proxy it to your front-end through App Proxies

See also:

Create product with Shopify Admin API

Can we get product by SKU using Shopify Storefront GraphQL API(NOT ADMIN)?

is that possible to use admin APIs in frontend directly in the store without app

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!