Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

151
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda