Skip to content
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

Nuxt 3 Integration #515

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ stream=true
prefer-workspace-packages=true
sort=false
bail=false
shamefully-hoist=true
5 changes: 5 additions & 0 deletions examples/nuxt3/complete/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
*.log
.nuxt
nuxt.d.ts
.output
29 changes: 29 additions & 0 deletions examples/nuxt3/complete/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Nuxt 3 Minimal Starter

We recommend to look at the [documentation](https://v3.nuxtjs.org).

## Setup

Make sure to install the dependencies

```bash
yarn install
```

## Development

Start the development server on http://localhost:3000

```bash
yarn dev
```

## Production

Build the application for production:

```bash
yarn build
```

Checkout the [deployment documentation](https://v3.nuxtjs.org/docs/deployment).
6 changes: 6 additions & 0 deletions examples/nuxt3/complete/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<template>
<div>
<!-- Remove this component to get started! -->
<NuxtWelcome />
</div>
</template>
3 changes: 3 additions & 0 deletions examples/nuxt3/complete/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { defineNuxtConfig } from 'nuxt3';

export default defineNuxtConfig({});
18 changes: 18 additions & 0 deletions examples/nuxt3/complete/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"private": true,
"scripts": {
"dev": "nuxt dev",
"build": "nuxt build",
"start": "node .output/server/index.mjs"
},
"devDependencies": {
"nuxt3": "^3.0.0-27257216.f5aea9f"
},
"dependencies": {
"@graphql-ez/nuxt": "workspace:^0.1.0",
"@graphql-ez/plugin-codegen": "workspace:^0.7.4",
"@graphql-ez/plugin-schema": "workspace:^0.8.0",
"graphql": "15.4.0-experimental-stream-defer.1",
"graphql-ez": "workspace:^0.13.2"
}
}
31 changes: 31 additions & 0 deletions examples/nuxt3/complete/server/api/graphql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { CreateApp } from '@graphql-ez/nuxt';
import { ezCodegen } from '@graphql-ez/plugin-codegen';
import { ezSchema, gql } from '@graphql-ez/plugin-schema';

const { buildApp } = CreateApp({
ez: {
plugins: [
ezSchema({
schema: {
typeDefs: gql`
type Query {
hello: String!
}
`,
resolvers: {
Query: {
hello() {
return 'Hello World!';
},
},
},
},
}),
ezCodegen(),
],
},
});

const { apiHandler } = buildApp();

export default apiHandler;
119 changes: 119 additions & 0 deletions examples/nuxt3/complete/src/ez.generated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import type { GraphQLResolveInfo } from 'graphql';
import type { EZContext } from 'graphql-ez';
export type Maybe<T> = T | null;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
export type ResolverFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => Promise<import('graphql-ez').DeepPartial<TResult>> | import('graphql-ez').DeepPartial<TResult>;
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
ID: string;
String: string;
Boolean: boolean;
Int: number;
Float: number;
};

export type Query = {
__typename?: 'Query';
hello: Scalars['String'];
};

export type ResolverTypeWrapper<T> = Promise<T> | T;

export type ResolverWithResolve<TResult, TParent, TContext, TArgs> = {
resolve: ResolverFn<TResult, TParent, TContext, TArgs>;
};
export type Resolver<TResult, TParent = {}, TContext = {}, TArgs = {}> =
| ResolverFn<TResult, TParent, TContext, TArgs>
| ResolverWithResolve<TResult, TParent, TContext, TArgs>;

export type SubscriptionSubscribeFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => AsyncIterator<TResult> | Promise<AsyncIterator<TResult>>;

export type SubscriptionResolveFn<TResult, TParent, TContext, TArgs> = (
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => TResult | Promise<TResult>;

export interface SubscriptionSubscriberObject<TResult, TKey extends string, TParent, TContext, TArgs> {
subscribe: SubscriptionSubscribeFn<{ [key in TKey]: TResult }, TParent, TContext, TArgs>;
resolve?: SubscriptionResolveFn<TResult, { [key in TKey]: TResult }, TContext, TArgs>;
}

export interface SubscriptionResolverObject<TResult, TParent, TContext, TArgs> {
subscribe: SubscriptionSubscribeFn<any, TParent, TContext, TArgs>;
resolve: SubscriptionResolveFn<TResult, any, TContext, TArgs>;
}

export type SubscriptionObject<TResult, TKey extends string, TParent, TContext, TArgs> =
| SubscriptionSubscriberObject<TResult, TKey, TParent, TContext, TArgs>
| SubscriptionResolverObject<TResult, TParent, TContext, TArgs>;

export type SubscriptionResolver<TResult, TKey extends string, TParent = {}, TContext = {}, TArgs = {}> =
| ((...args: any[]) => SubscriptionObject<TResult, TKey, TParent, TContext, TArgs>)
| SubscriptionObject<TResult, TKey, TParent, TContext, TArgs>;

export type TypeResolveFn<TTypes, TParent = {}, TContext = {}> = (
parent: TParent,
context: TContext,
info: GraphQLResolveInfo
) => Maybe<TTypes> | Promise<Maybe<TTypes>>;

export type IsTypeOfResolverFn<T = {}, TContext = {}> = (
obj: T,
context: TContext,
info: GraphQLResolveInfo
) => boolean | Promise<boolean>;

export type NextResolverFn<T> = () => Promise<T>;

export type DirectiveResolverFn<TResult = {}, TParent = {}, TContext = {}, TArgs = {}> = (
next: NextResolverFn<TResult>,
parent: TParent,
args: TArgs,
context: TContext,
info: GraphQLResolveInfo
) => TResult | Promise<TResult>;

/** Mapping between all available schema types and the resolvers types */
export type ResolversTypes = {
Query: ResolverTypeWrapper<{}>;
String: ResolverTypeWrapper<Scalars['String']>;
Boolean: ResolverTypeWrapper<Scalars['Boolean']>;
Int: ResolverTypeWrapper<Scalars['Int']>;
};

/** Mapping between all available schema types and the resolvers parents */
export type ResolversParentTypes = {
Query: {};
String: Scalars['String'];
Boolean: Scalars['Boolean'];
Int: Scalars['Int'];
};

export type QueryResolvers<
ContextType = EZContext,
ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']
> = {
hello?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
};

export type Resolvers<ContextType = EZContext> = {
Query?: QueryResolvers<ContextType>;
};

declare module 'graphql-ez' {
interface EZResolvers extends Resolvers<import('graphql-ez').EZContext> {}
}
3 changes: 3 additions & 0 deletions examples/nuxt3/complete/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./.nuxt/tsconfig.json"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"dev:mjs:yoga:express": "pnpm -r --filter @graphql-yoga/express dev -- --onSuccess \"cross-env PORT=3008 pnpm -r --filter example-yoga-express dev:mjs\"",
"dev:next": "pnpm -r --filter @graphql-ez/nextjs dev -- --onSuccess \"pnpm -r --filter example-complete-nextjs dev -- -p 3006\"",
"postinstall": "node patch.cjs",
"prepare": "husky install && bob-esbuild tsc && pnpm -r prepack",
"prepare": "husky install && bob-esbuild tsc && (pnpm -r prepack || exit 0)",
"pretty": "prettier --write \"**/*.{ts,tsx,json,yaml,js,cjs,mjs,mdx,md}\"",
"pretty:check": "prettier --check \"**/*.{ts,tsx,json,yaml,js,cjs,mjs,mdx}\"",
"test": "jest",
Expand Down
3 changes: 2 additions & 1 deletion packages/core/main/src/types/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export type IntegrationsNames =
| 'hapi'
| 'cloudflare'
| 'sveltekit'
| 'vercel';
| 'vercel'
| 'nuxt';

export interface AdapterFactoryContext {
integrationName: IntegrationsNames;
Expand Down
64 changes: 64 additions & 0 deletions packages/nuxt/main/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "@graphql-ez/nuxt",
"version": "0.1.0",
"homepage": "https://www.graphql-ez.com",
"repository": {
"type": "git",
"url": "https://github.com/PabloSzx/graphql-ez",
"directory": "packages/nuxt"
},
"license": "MIT",
"author": "PabloSz <[email protected]>",
"sideEffects": false,
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./*": {
"require": "./dist/*.js",
"import": "./dist/*.mjs"
}
},
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"scripts": {
"dev": "bob-esbuild watch",
"prepack": "bob-esbuild build",
"postpublish": "gh-release"
},
"dependencies": {
"@graphql-ez/utils": "workspace:^0.1.2",
"h3": "^0.3.3"
},
"devDependencies": {
"@types/node": "^16.11.3",
"changesets-github-release": "^0.0.4",
"graphql": "15.4.0-experimental-stream-defer.1",
"graphql-ez": "workspace:^0.13.2",
"jest": "^27.3.1",
"nuxt3": "^3.0.0-27255771.f78ec93",
"typescript": "^4.4.4"
},
"peerDependencies": {
"@types/node": "*",
"graphql": "*",
"graphql-ez": "workspace:^0.13.2",
"nuxt3": "*"
},
"peerDependenciesMeta": {
"graphql": {
"optional": true
},
"nuxt3": {
"optional": true
}
},
"engines": {
"node": "^12.20.0 || >=14.13.0"
},
"publishConfig": {
"directory": "dist"
}
}
Loading