diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2e2523e..047365b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -105,6 +105,8 @@ jobs:
- name: Run Tests
run: pnpm test -- --coverage
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: codecov/codecov-action@v3
diff --git a/examples/multi-client/nuxt.config.ts b/examples/multi-client/nuxt.config.ts
index a2bad9a..e2b858c 100644
--- a/examples/multi-client/nuxt.config.ts
+++ b/examples/multi-client/nuxt.config.ts
@@ -1,7 +1,7 @@
export default defineNuxtConfig({
compatibilityDate: '2024-11-05',
- modules: ['nuxt-graphql-client'],
+ modules: ['@nuxt/ui', 'nuxt-graphql-client'],
runtimeConfig: {
public: {
@@ -18,7 +18,8 @@ export default defineNuxtConfig({
},
rmorty: 'https://rickandmortyapi.com/graphql',
countries: 'https://countries.trevorblades.com/graphql',
- todos: 'https://nuxt-gql-server-2gl6xp7kua-ue.a.run.app/query'
+ todos: 'https://nuxt-gql-server-2gl6xp7kua-ue.a.run.app/query',
+ github: 'https://api.github.com/graphql'
}
}
}
diff --git a/examples/multi-client/pages/github/index.vue b/examples/multi-client/pages/github/index.vue
new file mode 100644
index 0000000..a6e96a6
--- /dev/null
+++ b/examples/multi-client/pages/github/index.vue
@@ -0,0 +1,59 @@
+
+
+
+
+ Github Example
+
+
+
+
+
+
+ Set Token
+
+
+
+ Clear Token
+
+
+
+
+
+ Load @me
+
+
+
+
+
+
+ Logged in as {{ data?.viewer?.login }}
+
+
+ Not logged in
+
+
+
+
+
+
diff --git a/examples/multi-client/queries/github/viewer.gql b/examples/multi-client/queries/github/viewer.gql
new file mode 100644
index 0000000..b56f48c
--- /dev/null
+++ b/examples/multi-client/queries/github/viewer.gql
@@ -0,0 +1,5 @@
+query viewer {
+ viewer {
+ login
+ }
+}
diff --git a/package.json b/package.json
index be36c6c..2b5bb5e 100644
--- a/package.json
+++ b/package.json
@@ -77,7 +77,8 @@
},
"pnpm": {
"overrides": {
- "node-fetch": "npm:node-fetch-native@latest"
+ "node-fetch": "npm:node-fetch-native@latest",
+ "nuxt-graphql-client": "workspace:*"
}
},
"packageManager": "pnpm@9.7.0"
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1479109..95e8488 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -6,6 +6,7 @@ settings:
overrides:
node-fetch: npm:node-fetch-native@latest
+ nuxt-graphql-client: workspace:*
importers:
@@ -91,8 +92,8 @@ importers:
specifier: latest
version: 3.14.0(@parcel/watcher@2.5.0)(@types/node@20.17.6)(eslint@9.14.0(jiti@2.4.0))(ioredis@5.4.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.24.4)(terser@5.36.0)(typescript@5.6.3)(vite@5.4.10(@types/node@20.17.6)(terser@5.36.0))
nuxt-graphql-client:
- specifier: latest
- version: 0.2.36(@parcel/watcher@2.5.0)(@types/node@20.17.6)(graphql-tag@2.12.6(graphql@16.9.0))(magicast@0.3.5)(rollup@4.24.4)(typescript@5.6.3)
+ specifier: workspace:*
+ version: link:../..
examples/extends:
devDependencies:
@@ -103,8 +104,8 @@ importers:
specifier: latest
version: 3.14.0(@parcel/watcher@2.5.0)(@types/node@20.17.6)(eslint@9.14.0(jiti@2.4.0))(ioredis@5.4.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.24.4)(terser@5.36.0)(typescript@5.6.3)(vite@5.4.10(@types/node@20.17.6)(terser@5.36.0))
nuxt-graphql-client:
- specifier: latest
- version: 0.2.36(@parcel/watcher@2.5.0)(@types/node@20.17.6)(graphql-tag@2.12.6(graphql@16.9.0))(magicast@0.3.5)(rollup@4.24.4)(typescript@5.6.3)
+ specifier: workspace:*
+ version: link:../..
examples/multi-client:
devDependencies:
@@ -115,8 +116,8 @@ importers:
specifier: latest
version: 3.14.0(@parcel/watcher@2.5.0)(@types/node@20.17.6)(eslint@9.14.0(jiti@2.4.0))(ioredis@5.4.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.24.4)(terser@5.36.0)(typescript@5.6.3)(vite@5.4.10(@types/node@20.17.6)(terser@5.36.0))
nuxt-graphql-client:
- specifier: latest
- version: 0.2.36(@parcel/watcher@2.5.0)(@types/node@20.17.6)(graphql-tag@2.12.6(graphql@16.9.0))(magicast@0.3.5)(rollup@4.24.4)(typescript@5.6.3)
+ specifier: workspace:*
+ version: link:../..
examples/starter:
devDependencies:
@@ -127,8 +128,8 @@ importers:
specifier: latest
version: 3.14.0(@parcel/watcher@2.5.0)(@types/node@20.17.6)(eslint@9.14.0(jiti@2.4.0))(ioredis@5.4.1)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.24.4)(terser@5.36.0)(typescript@5.6.3)(vite@5.4.10(@types/node@20.17.6)(terser@5.36.0))
nuxt-graphql-client:
- specifier: latest
- version: 0.2.36(@parcel/watcher@2.5.0)(@types/node@20.17.6)(graphql-tag@2.12.6(graphql@16.9.0))(magicast@0.3.5)(rollup@4.24.4)(typescript@5.6.3)
+ specifier: workspace:*
+ version: link:../..
playground:
devDependencies:
@@ -5121,9 +5122,6 @@ packages:
nuxt-config-schema@0.4.6:
resolution: {integrity: sha512-kHLWJFynj5QrxVZ1MjY2xmDaTSN1BCMLGExA+hMMLoCb3wn9TJlDVqnE/nSdUJPMRkNn/NQ5WP9NLA9vlAXRUw==}
- nuxt-graphql-client@0.2.36:
- resolution: {integrity: sha512-rtY05AptqJmKwTbD3PlbrdUNY4LDVfeIUBkulJLj5GVxlBRLLkcaQEZzFBp6AHow5QVNZgD5hN0R4Yjz7vjClQ==}
-
nuxt-icon@0.3.3:
resolution: {integrity: sha512-KdhJAigBGTP8/YIFZ3orwetk40AgLq6VQ5HRYuDLmv5hiDptor9Ro+WIdZggHw7nciRxZvDdQkEwi9B5G/jrkQ==}
@@ -7939,18 +7937,6 @@ snapshots:
transitivePeerDependencies:
- supports-color
- '@graphql-codegen/typescript-graphql-request@6.2.0(graphql-request@6.1.0(graphql@16.9.0))(graphql-tag@2.12.6(graphql@16.9.0))(graphql@16.9.0)':
- dependencies:
- '@graphql-codegen/plugin-helpers': 3.1.2(graphql@16.9.0)
- '@graphql-codegen/visitor-plugin-common': 2.13.1(graphql@16.9.0)
- auto-bind: 4.0.0
- graphql: 16.9.0
- graphql-request: 6.1.0(graphql@16.9.0)
- graphql-tag: 2.12.6(graphql@16.9.0)
- tslib: 2.6.3
- transitivePeerDependencies:
- - supports-color
-
'@graphql-codegen/typescript-graphql-request@6.2.0(graphql-request@7.1.2(graphql@16.9.0))(graphql-tag@2.12.6(graphql@16.9.0))(graphql@16.9.0)':
dependencies:
'@graphql-codegen/plugin-helpers': 3.1.2(graphql@16.9.0)
@@ -13551,33 +13537,6 @@ snapshots:
- supports-color
- webpack-sources
- nuxt-graphql-client@0.2.36(@parcel/watcher@2.5.0)(@types/node@20.17.6)(graphql-tag@2.12.6(graphql@16.9.0))(magicast@0.3.5)(rollup@4.24.4)(typescript@5.6.3):
- dependencies:
- '@graphql-codegen/cli': 5.0.3(@parcel/watcher@2.5.0)(@types/node@20.17.6)(graphql@16.9.0)(typescript@5.6.3)
- '@graphql-codegen/typescript': 4.1.1(graphql@16.9.0)
- '@graphql-codegen/typescript-graphql-request': 6.2.0(graphql-request@6.1.0(graphql@16.9.0))(graphql-tag@2.12.6(graphql@16.9.0))(graphql@16.9.0)
- '@graphql-codegen/typescript-operations': 4.3.1(graphql@16.9.0)
- '@nuxt/kit': 3.14.0(magicast@0.3.5)(rollup@4.24.4)
- defu: 6.1.4
- graphql: 16.9.0
- graphql-request: 6.1.0(graphql@16.9.0)
- knitwork: 1.1.0
- ohash: 1.1.4
- scule: 1.3.0
- transitivePeerDependencies:
- - '@parcel/watcher'
- - '@types/node'
- - bufferutil
- - cosmiconfig-toml-loader
- - enquirer
- - graphql-tag
- - magicast
- - rollup
- - supports-color
- - typescript
- - utf-8-validate
- - webpack-sources
-
nuxt-icon@0.3.3(magicast@0.3.5)(rollup@4.24.4)(vue@3.5.12(typescript@5.6.3)):
dependencies:
'@iconify/vue': 4.1.2(vue@3.5.12(typescript@5.6.3))
diff --git a/test/multi-client.test.ts b/test/multi-client.test.ts
index fc9ada4..a4dd7f6 100644
--- a/test/multi-client.test.ts
+++ b/test/multi-client.test.ts
@@ -33,4 +33,13 @@ describe('test multiple clients', () => {
expect(result).toContain('
First Episode: Pilot
')
expect(result).toContain('Name: Morty Smith
')
})
+
+ it('retrieve github user details', async () => {
+ const token = process.env.GH_TOKEN
+ const result = await $fetch('/github', {
+ headers: { Cookie: token ? `gql:github=${token}` : '' }
+ })
+
+ expect(result).toContain('Logged in as github-actions[bot]')
+ })
})