I am quite new and having some difficulties getting an output when running a GraphQL query on a shopify scriptTag.
My current code looks like:
const test4 = gql`
query {
scriptTags(first: 4) {
edges {
node {
id
src
}
}
}
}
`;
const GiveData = () => (
<Query query={test4}>
{({ loading, error, data }) => {
if (loading) return "Loading...";
if (error) return `Error! ${error.message}`;
return (
<div>
<p> hi1 </p>
{data.scriptTags.edges.map(({ node }) => (
<div key={node.src}>
<p>
hi2 {node.src}
</p>
</div>
))}
</div>
);
}}
</Query>
);
My page is rendering the "hi1" text paragraph, but the "hi2" and actual data never loads. My console is also not outputting any error.
The query code itself works perfectly if I run it through the Shopify GraphiQL App, so I assume it isn't that. I believe I am doing something wrong within the GiveData constant, but not sure what.
Thanks in advance for any help or hints.
More context: I have a basic shopify app setup, using react + node.js setup (based on shopify's templates & tutorial).
My server.js file has the script tag scopes included:
...
createShopifyAuth({
apiKey: SHOPIFY_API_KEY,
secret: SHOPIFY_API_SECRET_KEY,
scopes: ['read_products', 'write_products', 'read_script_tags', 'write_script_tags'],
...
I have been able to write a script tag, as it shows up in the Shopify GraphiQL App. Screenshot of output .
I am also able to get an output from a different GraphQL query. For example this
const test3 = gql`
query {
shop {
id
}
}
`;
with the same basic GiveData constant above, will output a result if I have ...{data.shop.id}... in my return field.
I am primarily wanting to query the script tags I've been able to write myself (not anything outside my app).