Skip to content

Commit

Permalink
add @graphql-ez/nuxt ez integration
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloSzx committed Oct 27, 2021
1 parent 7d52fda commit 3828c36
Show file tree
Hide file tree
Showing 8 changed files with 431 additions and 8 deletions.
8 changes: 6 additions & 2 deletions examples/nuxt3/complete/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
"start": "node .output/server/index.mjs"
},
"devDependencies": {
"nuxt3": "^3.0.0-27249044.7d918e1"
"nuxt3": "^3.0.0-27254511.41ff3b8"
},
"dependencies": {
"unenv": "^0.4.0"
"@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> {}
}
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-27254511.41ff3b8",
"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

0 comments on commit 3828c36

Please sign in to comment.