Skip to content

Instantly share code, notes, and snippets.

@enamhasan
Created January 11, 2022 13:45
Show Gist options
  • Save enamhasan/251cb5ef5c7904f07a40083fc092b3c3 to your computer and use it in GitHub Desktop.
Save enamhasan/251cb5ef5c7904f07a40083fc092b3c3 to your computer and use it in GitHub Desktop.
Create ScriptTag via Shopify node react App via GraphQL
import gql from 'graphql-tag';
import { useQuery, useMutation } from '@apollo/react-hooks';
import { Button, Card, Layout, Page, ResourceList, Stack } from '@shopify/polaris';
const CREATE_SCRIPT_TAG = gql`
mutation scriptTagCreate($input: ScriptTagInput!) {
scriptTagCreate(input: $input) {
scriptTag {
id
}
userErrors {
field
message
}
}
}
`;
function ScriptPage() {
const [createScripts] = useMutation(CREATE_SCRIPT_TAG);
return (
<div>
<h1>Create and delete script tag, META FILEDS</h1>
<button
type='submit' onClick={() => {
createScripts({ variables: { input: { src: "https://71a9-103-140-82-239.ngrok.io/test-scripts.js", displayScope: "ALL" } } } )
}
}
>
Create script tag</button >
</div>
)
}
export default ScriptPage;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment