Skip to content

update @nuxt/module-builder, unify package exports #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions build.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
entries: [
'./src/client-options.ts',
'./src/server-options.ts',
'./src/utils.ts',
],
externals: [
'ofetch',
'h3',
Expand All @@ -21,8 +26,13 @@ export default defineBuildConfig({
'@polka/url',
'mrmime',
'#nuxt-graphql-middleware/response',
'#nuxt-graphql-middleware/client-options',
'#nuxt-graphql-middleware/server-options',
'micromatch',
'@clack/core',
'is-unicode-supported',
],
replace: {
'process.env.PLAYGROUND_MODULE_BUILD': 'undefined',
},
})
2 changes: 1 addition & 1 deletion client/components/DocumentDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</template>

<script lang="ts" setup>
import type { RpcItem } from './../../src/rpc-types'
import type { RpcItem } from './../../src/build/types/rpc'
const props = defineProps<RpcItem & { serverApiPrefix: string }>()

const errorsMapped = computed(() => {
Expand Down
14 changes: 8 additions & 6 deletions client/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ import type {
ServerFunctions,
ClientFunctions,
RpcItem,
} from './../../src/rpc-types'
} from './../../src/build/types/rpc'

const miniSearch = new MiniSearch({
const miniSearch = new MiniSearch<RpcItem>({
fields: ['id', 'source', 'name', 'filePath', 'identifier'],
storeFields: ['id', 'source', 'name', 'identifier', 'filePath'],
searchOptions: {
Expand Down Expand Up @@ -124,18 +124,20 @@ function copyToClipboard(item: RpcItem) {
textArea.select()

try {
const successful = document.execCommand('copy')
} catch (_e) {}
document.execCommand('copy')
} catch {
// Noop
}

document.body.removeChild(textArea)
}

const documentsFiltered = computed(() => {
const documentsFiltered = computed<RpcItem[]>(() => {
if (!search.value) {
return documents.value
}

const results = miniSearch.search(search.value)
return results
return results as unknown as RpcItem[]
})
</script>
6 changes: 3 additions & 3 deletions docs/configuration/client-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ called `graphqlMiddleware.clientOptions.ts` in your `app` directory (usually
::: code-group

```typescript [~/app/graphqlMiddleware.clientOptions.ts]
import { defineGraphqlClientOptions } from 'nuxt-graphql-middleware/dist/runtime/clientOptions'
import { defineGraphqlClientOptions } from 'nuxt-graphql-middleware/client-options'

export default defineGraphqlClientOptions({})
```
Expand All @@ -42,7 +42,7 @@ values.
::: code-group

```typescript [~/app/graphqlMiddleware.clientOptions.ts]
import { defineGraphqlClientOptions } from 'nuxt-graphql-middleware/dist/runtime/clientOptions'
import { defineGraphqlClientOptions } from 'nuxt-graphql-middleware/client-options'

export default defineGraphqlClientOptions<{
language: string
Expand Down Expand Up @@ -97,7 +97,7 @@ On the server you can then access this client context from within all
::: code-group

```typescript [~/server/graphqlMiddleware.serverOptions.ts]
import { defineGraphqlServerOptions } from 'nuxt-graphql-middleware/dist/runtime/serverOptions'
import { defineGraphqlServerOptions } from 'nuxt-graphql-middleware/server-options'

export default defineGraphqlServerOptions({
graphqlEndpoint(event, operation, operationName, context) {
Expand Down
4 changes: 3 additions & 1 deletion docs/configuration/module-utils.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Module Utils

These utils can be imported from `nuxt-graphql-middleware/utils`.

::: warning

These utils can **only** be used in other modules. Importing them in any other
Expand All @@ -19,7 +21,7 @@ of certain types and fields in the schema.

```typescript
import { defineNuxtModule } from '@nuxt/kit'
import { useGraphqlModuleContext } from 'nuxt-graphql-middleware'
import { useGraphqlModuleContext } from 'nuxt-graphql-middleware/utils'
import { isObjectType } from 'graphql'

type Feature = 'comments' | 'blog' | 'analytics'
Expand Down
Loading
Loading