Skip to content

Commit 59fc568

Browse files
authored
Merge pull request #2 from guendev/update
chore: setup npm publishing with provenance
2 parents b11a7d8 + 59c1932 commit 59fc568

File tree

8 files changed

+347
-1
lines changed

8 files changed

+347
-1
lines changed

β€Ž.changeset/hot-moons-sort.mdβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@vue3-apollo/core": minor
3+
"@vue3-apollo/nuxt": minor
4+
---
5+
6+
Setup package publishing with provenance to npm registry

β€Ž.github/workflows/release.ymlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,5 @@ jobs:
5555
title: 'chore: release packages'
5656
env:
5757
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
5958
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
59+
NPM_CONFIG_PROVENANCE: true

β€Žpackages/core/LICENSEβ€Ž

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Guen <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

β€Žpackages/core/README.mdβ€Ž

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# @vue3-apollo/core
2+
3+
> 🧩 Composable utilities for using [Apollo Client v4](https://www.apollographql.com/docs/react/) with [Vue 3](https://vuejs.org/).
4+
5+
Vue3 Apollo Core provides a **lightweight, composable-first integration** between Vue 3 and Apollo Client, allowing you to perform GraphQL queries, mutations, and subscriptions in a fully reactive way.
6+
7+
## ✨ Features
8+
9+
- πŸͺΆ Minimal and tree-shakeable
10+
- πŸ” Reactive GraphQL queries & mutations via Vue composables
11+
- ⚑ Multiple client support (default + named clients)
12+
- 🧠 TypeScript-first API
13+
- 🧩 Seamless integration with Nuxt via [`@vue3-apollo/nuxt`](https://www.npmjs.com/package/@vue3-apollo/nuxt)
14+
- πŸ“„ Full documentation at [vue3-apollo.guen.dev](https://vue3-apollo.guen.dev/)
15+
16+
## πŸ“¦ Installation
17+
18+
You can install using your preferred package manager:
19+
20+
```bash
21+
npm install @vue3-apollo/core @apollo/client graphql
22+
```
23+
24+
## πŸš€ Getting Started
25+
26+
### 1. Create an Apollo Client
27+
28+
```ts
29+
import { ApolloClient, InMemoryCache, HttpLink } from '@apollo/client/core'
30+
31+
export const defaultClient = new ApolloClient({
32+
cache: new InMemoryCache(),
33+
link: new HttpLink({
34+
// Example public GraphQL API
35+
uri: 'https://graphqlplaceholder.vercel.app/graphql',
36+
}),
37+
})
38+
```
39+
40+
### 2. Register the Plugin
41+
42+
```ts
43+
import { createApp } from 'vue'
44+
import { apolloPlugin } from '@vue3-apollo/core'
45+
import { defaultClient, analyticsClient } from './apollo-clients'
46+
47+
const app = createApp(App)
48+
49+
app.use(apolloPlugin, {
50+
clients: {
51+
default: defaultClient,
52+
analytics: analyticsClient,
53+
},
54+
})
55+
```
56+
57+
This injects Apollo clients into your Vue app, making them available across composables and components.
58+
59+
### 3. Use in a Component
60+
61+
```vue
62+
<script setup lang="ts">
63+
import { useQuery } from '@vue3-apollo/core'
64+
import gql from 'graphql-tag'
65+
66+
const GET_POSTS = gql`
67+
query Posts {
68+
posts {
69+
id
70+
title
71+
body
72+
}
73+
}
74+
`
75+
76+
const { result, loading, error } = useQuery(GET_POSTS)
77+
</script>
78+
79+
<template>
80+
<div v-if="loading">Loading...</div>
81+
<div v-else-if="error">{{ error.message }}</div>
82+
<ul v-else>
83+
<li v-for="post in result.posts" :key="post.id">
84+
<strong>{{ post.title }}</strong> β€” {{ post.body }}
85+
</li>
86+
</ul>
87+
</template>
88+
```
89+
90+
## 🧠 Composables Overview
91+
92+
| Composable | Description |
93+
|-------------|--------------|
94+
| `useQuery` | Reactive GraphQL query |
95+
| `useLazyQuery` | Run query on demand |
96+
| `useMutation` | Execute GraphQL mutations |
97+
| `useSubscription` | Subscribe to GraphQL streams |
98+
| `useApolloClient` | Access current Apollo client |
99+
| `provideApolloClients` / `useApolloClients` | Manage multiple clients |
100+
101+
See the [full API reference](https://vue3-apollo.guen.dev/core/composables/use-query) for details.
102+
103+
---
104+
105+
## 🧩 Multi-Client Example
106+
107+
You can register and switch between multiple clients:
108+
109+
```ts
110+
const { result: analyticsData } = useQuery(ANALYTICS_QUERY, null, {
111+
clientId: 'analytics',
112+
})
113+
```
114+
115+
## 🧰 TypeScript Support
116+
117+
All composables are fully typed, providing autocompletion and inference for query variables and responses.
118+
119+
```ts
120+
const { result } = useQuery<{ posts: { id: string; title: string }[] }>(GET_POSTS)
121+
```
122+
123+
## πŸ§‘β€πŸ’» Contributing
124+
125+
This package is part of the [Vue3 Apollo monorepo](https://github.com/guendev/vue3-apollo).
126+
127+
To develop locally:
128+
129+
```bash
130+
pnpm install
131+
pnpm build
132+
pnpm dev:docs
133+
```
134+
135+
## πŸ“„ License
136+
137+
[MIT](https://github.com/guendev/vue3-apollo/blob/main/LICENSE)
138+
139+
## πŸ”— Links
140+
141+
- 🌐 [Documentation](https://vue3-apollo.guen.dev/)
142+
- πŸ’Ύ [GitHub Repository](https://github.com/guendev/vue3-apollo)
143+
- πŸ“¦ [npm - @vue3-apollo/core](https://www.npmjs.com/package/@vue3-apollo/core)
144+
- 🧱 [Nuxt Integration - @vue3-apollo/nuxt](https://www.npmjs.com/package/@vue3-apollo/nuxt)

β€Žpackages/core/package.jsonβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
},
7575
"publishConfig": {
7676
"access": "public",
77+
"registry": "https://registry.npmjs.org/",
7778
"provenance": true
7879
}
7980
}

β€Žpackages/nuxt/LICENSEβ€Ž

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Guen <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

β€Žpackages/nuxt/README.mdβ€Ž

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# @vue3-apollo/nuxt
2+
3+
> ⚑️ Lightweight Nuxt module for Apollo Client v4 with SSR and WebSocket subscription support.
4+
5+
This package provides a seamless way to integrate Apollo Client into your **Nuxt 4** application using Vue 3’s Composition API β€” with full support for SSR, multi-client configuration, and GraphQL subscriptions.
6+
7+
## ✨ Features
8+
9+
- πŸ’¨ Zero-config setup for Nuxt 4
10+
- 🧩 Built on [`@vue3-apollo/core`](https://www.npmjs.com/package/@vue3-apollo/core)
11+
- πŸ” Supports HTTP & WebSocket links
12+
- 🧠 SSR-safe authentication via cookies
13+
- βš™οΈ TypeScript support
14+
- πŸ”„ Multi-client configuration
15+
16+
## πŸ“¦ Installation
17+
18+
You can install using your preferred package manager:
19+
20+
```bash
21+
# npm
22+
npm i @vue3-apollo/nuxt @apollo/client graphql
23+
```
24+
25+
## πŸš€ Quick Start
26+
27+
Configure Apollo directly inside your `nuxt.config.ts`:
28+
29+
```ts
30+
// nuxt.config.ts
31+
export default defineNuxtConfig({
32+
modules: ['@vue3-apollo/nuxt'],
33+
apollo: {
34+
clients: {
35+
default: {
36+
// HTTP link
37+
httpEndpoint: 'https://graphqlplaceholder.vercel.app/graphql',
38+
39+
// WebSocket link (optional; install `graphql-ws` in your project)
40+
wsEndpoint: 'wss://graphqlplaceholder.vercel.app/graphql'
41+
}
42+
},
43+
44+
// Common transport options
45+
httpLinkOptions: { credentials: 'include' },
46+
wsLinkOptions: { retryAttempts: 3 }
47+
}
48+
})
49+
```
50+
51+
Use anywhere in your app:
52+
53+
```ts
54+
// Query
55+
const { result, loading, error } = useQuery(GET_POSTS)
56+
57+
// Subscription
58+
const { result: livePost } = useSubscription(POST_ADDED)
59+
```
60+
61+
> **Note:**
62+
> 1. To enable WebSocket subscriptions, install [`graphql-ws`](https://github.com/enisdenjo/graphql-ws).
63+
> 2. WebSocket connections only support the **`graphql-ws`** subprotocol.
64+
65+
### Install `graphql-ws`
66+
67+
```bash
68+
# npm
69+
npm i graphql-ws
70+
71+
# pnpm
72+
pnpm add graphql-ws
73+
74+
# bun
75+
bun add graphql-ws
76+
```
77+
78+
## πŸ” Authentication
79+
80+
Tokens are read from cookies (SSR-safe) by default.
81+
82+
```ts
83+
// nuxt.config.ts
84+
export default defineNuxtConfig({
85+
modules: ['@vue3-apollo/nuxt'],
86+
apollo: {
87+
auth: {
88+
tokenName: 'auth-token', // default: apollo:{clientId}:token
89+
authType: 'Bearer', // set null to send raw token
90+
authHeader: 'Authorization' // custom header name
91+
}
92+
93+
// or disable entirely:
94+
// auth: false
95+
}
96+
})
97+
```
98+
99+
## 🧠 Multi-Client Usage
100+
101+
Register multiple clients and switch between them dynamically:
102+
103+
```ts
104+
// nuxt.config.ts
105+
export default defineNuxtConfig({
106+
modules: ['@vue3-apollo/nuxt'],
107+
apollo: {
108+
clients: {
109+
default: { httpEndpoint: 'https://api.main/graphql' },
110+
analytics: { httpEndpoint: 'https://api.analytics/graphql' }
111+
}
112+
}
113+
})
114+
```
115+
116+
```ts
117+
// Example composable
118+
const { result } = useQuery(GET_ANALYTICS, null, { clientId: 'analytics' })
119+
```
120+
121+
---
122+
123+
## 🧩 Integration with Vue Composables
124+
125+
All core composables (`useQuery`, `useMutation`, `useSubscription`, etc.) are automatically available via `@vue3-apollo/core`.
126+
127+
```ts
128+
const { result, loading } = useQuery(GET_USER)
129+
```
130+
131+
## πŸ§‘β€πŸ’» Contributing
132+
133+
This package is part of the [Vue3 Apollo monorepo](https://github.com/guendev/vue3-apollo).
134+
135+
To develop locally:
136+
137+
```bash
138+
pnpm install
139+
pnpm build
140+
pnpm dev:docs
141+
```
142+
143+
## πŸ“„ License
144+
145+
[MIT](https://github.com/guendev/vue3-apollo/blob/main/LICENSE)
146+
147+
## πŸ”— Links
148+
149+
- 🌐 [Documentation](https://vue3-apollo.guen.dev/)
150+
- πŸ’Ύ [GitHub Repository](https://github.com/guendev/vue3-apollo)
151+
- πŸ“¦ [npm - @vue3-apollo/nuxt](https://www.npmjs.com/package/@vue3-apollo/nuxt)
152+
- 🧱 [Core Composables - @vue3-apollo/core](https://www.npmjs.com/package/@vue3-apollo/core)

β€Žpackages/nuxt/package.jsonβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
},
7979
"publishConfig": {
8080
"access": "public",
81+
"registry": "https://registry.npmjs.org/",
8182
"provenance": true
8283
}
8384
}

0 commit comments

Comments
Β (0)