# sveltefy

> Shopify GraphQl for svelte and svelte kit.

Latest version **0.0.3** (published 2023-01-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install sveltefy
pnpm add sveltefy
yarn add sveltefy
bun add sveltefy
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2023-01-26 |
| First published | 2023-01-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 329.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | anthony809 |
| Maintainers | anthony809 |
| Keywords | Svelte, Shopify, GraphQl |

## Links

- npm: https://www.npmjs.com/package/sveltefy
- npm.io page: https://npm.io/package/sveltefy

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2023-01-26
- 0.0.2 — 2023-01-24
- 0.0.1 — 2023-01-24
- 0.0.0 — 2023-01-24

## README

## SvelteFy | A package to use Shopify GraphQl the svelte way
#### Things to do before using package
Make sure you create a ```.env``` file and set the following variables
```bash
# SHOPIFY STORE URL (PUBLIC)
SHOPIFY_STORE_URL="https://store.myshopify.com"
PUBLIC_SHOPIFY_STORE_URL="https://store.myshopify.com"
# SHOPIFY CLIENT / STORE FRONT TOKEN (PUBLIC)
SHOPIFY_STORE_TOKEN="token_here_yes_here_lol"
PUBLIC_SHOPIFY_STORE_TOKEN="token_here_yes_here_lol" 
# SHOPIFY ADMIN TOKEN (SECURE)
SHOPIFY_STORE_ADMIN_TOKEN = "token_here_yes_here_lol"
```
### Import package
You can import client/public,server (client but server side) or admin (server side)
Import client
``` typescript
import SvelteFy from "svelteFy";
```
Import client (server side)
``` typescript
import SvelteFy from "svelteFy/server";
```
Import admin (server side)
``` typescript
import SvelteFy from "svelteFy/admin";
```
From ```svelteFy/server``` and ```svelteFy/admin``` you can import the function ```generateTypes``` to generate types for response
``` typescript
import SvelteFy, { generateTypes } from "svelteFy/server";
// Or
import SvelteFy, { generateTypes } from "svelteFy/admin";
```
How to query data
``` typescript
import SvelteFy, { gql,generateTypes } from "svelteFy/server";
// Input for GraphQl request / parameters for function
const input = `handle:"product-handle"`
// Variables for GraphQl request
const variables = {}
// Data to return from GraphQl request
const dataToReturn = gql`{ title id handle }`
// GraphQl response
const response = await SvelteFy.query.product(input,variables,returnData)
```
Always check to see if you got any error using response.error:```boolean```
Good response
``` typescript
{
    "data": {
        "product": {
            "id": "gid://shopify/Product/6864601907223",
            "title": "HarmonyPlug"
        }
    },
    "error": false
}
```
Bad response
``` typescript
{
    "data": {
        "message": "Parse error on \"product-handle\" (STRING) at [2, 25]",
        "locations": [
            {
                "line": 2,
                "column": 25
            }
        ]
    },
    "error": true
}
```
NO COMPLETED

---
_Source: https://npm.io/package/sveltefy · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
