Skip to content

Commit c58ce8b

Browse files
committed
feat: Added client side storefront api access
Signed-off-by: Frederik Bußmann <[email protected]>
1 parent 4d8a7c0 commit c58ce8b

19 files changed

Lines changed: 194 additions & 38 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ jobs:
3737
- name: Release module
3838
run: |
3939
pnpm set //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}
40-
pnpm release
40+
pnpm release || true

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
# Nuxt Shopify
66

7+
[![Github Actions][github-actions-src]][github-actions-href]
78
[![NPM version][npm-version-src]][npm-version-href]
89
[![NPM downloads][npm-downloads-src]][npm-downloads-href]
910
[![License][license-src]][license-href]
@@ -168,14 +169,17 @@ For a full example, see [Admin API examples](https://konkonam.github.io/nuxt-sho
168169

169170
Published under the [MIT License](https://github.com/konkonam/nuxt-shopify/tree/main/LICENSE).
170171

172+
[github-actions-src]: https://github.com/konkonam/nuxt-shopify/actions/workflows/test.yml/badge.svg
173+
[github-actions-href]: https://github.com/konkonam/nuxt-shopify/actions
174+
171175
[npm-version-src]: https://img.shields.io/npm/v/@konkonam/nuxt-shopify/latest.svg?style=flat&colorA=18181B&colorB=31C553
172176
[npm-version-href]: https://npmjs.com/package/@konkonam/nuxt-shopify
173177

174178
[npm-downloads-src]: https://img.shields.io/npm/dm/@konkonam/nuxt-shopify.svg?style=flat&colorA=18181B&colorB=31C553
175179
[npm-downloads-href]: https://npmjs.com/package/@konkonam/nuxt-shopify
176180

177-
[license-src]: https://img.shields.io/github/license/konkonam/nuxt-shopify.svg?style=flat&colorA=18181B&colorB=28CF8D
181+
[license-src]: https://img.shields.io/github/license/konkonam/nuxt-shopify.svg?style=flat&colorA=18181B&colorB=31C553
178182
[license-href]: https://github.com/konkonam/nuxt-shopify/tree/main/LICENSE
179183

180-
[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js
184+
[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt
181185
[nuxt-href]: https://nuxt.com

eslint.config.mjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'
2+
3+
export default createConfigForNuxt({
4+
features: {
5+
tooling: true,
6+
typescript: {
7+
strict: true,
8+
},
9+
stylistic: {
10+
indent: 4,
11+
semi: false,
12+
quotes: 'single',
13+
},
14+
},
15+
}).override('nuxt/vue/rules', {
16+
rules: {
17+
'vue/multi-word-component-names': 'off',
18+
},
19+
}).override('nuxt/import/rules', {
20+
rules: {
21+
'import/order': ['error', {
22+
'groups': [
23+
'type',
24+
['builtin', 'external'],
25+
['internal', 'parent', 'sibling', 'index', 'object'],
26+
],
27+
'newlines-between': 'always',
28+
'alphabetize': {
29+
order: 'asc',
30+
},
31+
}],
32+
},
33+
})

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,17 @@
2929
"scripts": {
3030
"build": "nuxt-module-build build",
3131
"build:docs": "vitepress build docs",
32-
"dev": "nuxi dev playgrounds/playground",
32+
"dev": "pnpm run --filter=playground dev",
33+
"dev:v4": "pnpm run --filter=playground-nuxt-v4 dev",
3334
"dev:docs": "vitepress dev docs",
34-
"dev:v4": "nuxi dev playgrounds/playground-nuxt-v4",
3535
"preview:docs": "vitepress preview docs",
3636
"release": "pnpm publish --no-git-checks",
3737
"lint": "eslint .",
3838
"typecheck": "vue-tsc --noEmit",
3939
"analyze": "pnpm run --filter=./playgrounds/playground analyze",
4040
"prepare": "nuxt-module-build prepare",
4141
"prepare:dev": "pnpm run --filter=./playgrounds/* prepare",
42-
"cleanup": "pnpm run --filter=./playgrounds/playground cleanup && nuxi cleanup && rm -rf node_modules"
42+
"cleanup": "pnpm run --filter=* cleanup && nuxi cleanup"
4343
},
4444
"dependencies": {
4545
"@graphql-codegen/cli": "^5.0.5",

playgrounds/playground-nuxt-v4/nuxt.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as dotenv from 'dotenv'
22

3-
dotenv.config()
3+
dotenv.config({
4+
path: '../../.env',
5+
})
46

57
export default defineNuxtConfig({
68
modules: [
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
{
2-
"name": "playground",
2+
"name": "playground-v4",
33
"private": true,
44
"type": "module",
55
"scripts": {
6-
"dev": "nuxi dev",
7-
"build": "nuxi build",
8-
"prepare": "nuxi prepare",
9-
"analyze": "nuxi analyze",
10-
"cleanup": "nuxi cleanup && rm -rf node_modules"
6+
"dev": "nuxt dev",
7+
"build": "nuxt build",
8+
"prepare": "nuxt prepare",
9+
"analyze": "nuxt analyze",
10+
"cleanup": "nuxt cleanup",
11+
"typecheck": "vue-tsc --noEmit"
1112
},
1213
"dependencies": {
1314
"nuxt": "^3.16.2",
1415
"zod": "^3.24.3"
1516
}
16-
}
17+
}

playgrounds/playground/nuxt.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as dotenv from 'dotenv'
22

3-
dotenv.config()
3+
dotenv.config({
4+
path: '../../.env',
5+
})
46

57
export default defineNuxtConfig({
68
modules: [
@@ -20,6 +22,8 @@ export default defineNuxtConfig({
2022
storefront: {
2123
apiVersion: process.env.SHOPIFY_STOREFRONT_API_VERSION ?? '',
2224
publicAccessToken: process.env.SHOPIFY_STOREFRONT_PUBLIC_TOKEN ?? '',
25+
26+
client: true,
2327
},
2428
},
2529
},

playgrounds/playground/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
"private": true,
44
"type": "module",
55
"scripts": {
6-
"dev": "nuxi dev",
7-
"build": "nuxi build",
8-
"prepare": "nuxi prepare",
9-
"analyze": "nuxi analyze",
10-
"cleanup": "nuxi cleanup && rm -rf node_modules"
6+
"dev": "nuxt dev",
7+
"build": "nuxt build",
8+
"prepare": "nuxt prepare",
9+
"analyze": "nuxt analyze",
10+
"cleanup": "nuxt cleanup",
11+
"typecheck": "vue-tsc --noEmit"
1112
},
1213
"dependencies": {
1314
"nuxt": "^3.16.2",
1415
"zod": "^3.24.3"
1516
}
16-
}
17+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<script type="setup" setup lang="ts">
2+
const storefront = useStorefront()
3+
4+
const { data } = await storefront.request(`#graphql
5+
query FetchFirstThreeProducts($first: Int) {
6+
products(first: $first) {
7+
nodes {
8+
id
9+
title
10+
description
11+
}
12+
}
13+
}
14+
`, {
15+
variables: {
16+
first: 3,
17+
},
18+
})
19+
</script>
20+
21+
<template>
22+
<div>
23+
<pre>{{ data?.products }}</pre>
24+
</div>
25+
</template>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"extends": "./.nuxt/tsconfig.json"
2+
"extends": "./.nuxt/tsconfig.json",
33
}

0 commit comments

Comments
 (0)