Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

GraphQL querying by useShopifyQuery() in new version CLI (started from 3.2)

GraphQL querying by useShopifyQuery() in new version CLI (started from 3.2)

Alex-Bosatski
Visitor
1 0 0

Hello,

Does anyone know a way to make hooks work in the new version of CLI/templates (started from v. 3.2)?

I moved the file useShopifyQuery.js to the new template, but all executions fail with an Error 500.

An example of code below:

 

 

 

import { useShopifyQuery } from "../hooks/useShopifyQuery.js";
import { gql } from "graphql-request";
export const GET_APP_ID = gql`
    query {
        AppInstallation {
            id        }
    }
`;
export default function HomePage() {

    const data = useShopifyQuery({
        key: 'ShopId',
        query: GET_APP_ID,
    })

    console.log(data)

    return (
        <div>Test</div>    );
}

 

 

 

 

 

 

Replies 0 (0)