Shopify / shopify-app-template-node

MIT License
892 stars 402 forks source link

Auth Callback: GraphQL query returned errors #1261

Closed ICeZer0 closed 1 year ago

ICeZer0 commented 1 year ago

Issue summary

After a user approves the token scopes and installs the app, the callback URL presents the error GraphQL query returned errors.

I am using the default shopifyApp config

const shopify = shopifyApp({
  api: {
    apiVersion: LATEST_API_VERSION,
    restResources,
    billing: billingConfig, // or replace with billingConfig above to enable example billing
  },
  auth: {
    path: "/api/auth",
    callbackPath: "/api/auth/callback",
  },
  webhooks: {
    path: "/api/webhooks",
  },
  // This should be replaced with your preferred storage strategy
  sessionStorage: new SQLiteSessionStorage(DB_PATH),
});
2023-04-30 12:19:55 │ backend  │ [shopify-app/INFO] Handling request to complete OAuth process
2023-04-30 12:19:55 │ backend  │ [shopify-api/INFO] Completing OAuth | {shop: X.myshopify.com}
2023-04-30 12:19:56 │ backend  │ [shopify-app/INFO] Running validateAuthenticatedSession
2023-04-30 12:19:56 │ backend  │ [shopify-api/INFO] Creating new session | {shop:X.myshopify.com, isOnline: false}
2023-04-30 12:19:56 │ backend  │ [shopify-api/INFO] Registering webhooks | {shop: X.myshopify.com}
2023-04-30 12:19:56 │ backend  │ [shopify-app/INFO] Request session has a valid access token | {shop: X.myshopify.com}
2023-04-30 12:19:56 │ backend  │ In getLocations
2023-04-30 12:19:56 │ backend  │ In getInventoryLevelsForLocations
2023-04-30 12:19:56 │ backend  │ In getInventoryItems
2023-04-30 12:19:56 │ backend  │ [shopify-app/ERROR] Failed to complete OAuth with error: Error: GraphQL query returned errors

Expected behavior

callbackPath /api/auth/callback, should redirect user to homepage.

Actual behavior

My page displays the error GraphQL query returned errors. I must redirect to admin homepage before I can see the app.

Steps to reproduce the problem

  1. Install shopify app
  2. Watch redirect
  3. See error
ICeZer0 commented 1 year ago

The issue was caused by a modification to the webhooks file..