Created
January 11, 2022 13:45
-
-
Save enamhasan/251cb5ef5c7904f07a40083fc092b3c3 to your computer and use it in GitHub Desktop.
Create ScriptTag via Shopify node react App via GraphQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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