Skip to content

Commit

Permalink
update snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloSzx committed Jun 21, 2021
1 parent 286fd29 commit b509295
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 143 deletions.
49 changes: 22 additions & 27 deletions examples/mercurius/src/generated/mercurius.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {
import type {
GraphQLResolveInfo,
GraphQLScalarType,
GraphQLScalarTypeConfig,
} from 'graphql';
import { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
import type { MercuriusContext } from 'mercurius';
import type { TypedDocumentNode as DocumentNode } from '@graphql-typed-document-node/core';
export type Maybe<T> = T | null;
export type Exact<T extends { [key: string]: unknown }> = {
[K in keyof T]: T[K];
Expand Down Expand Up @@ -306,7 +307,7 @@ export type ResolversParentTypes = {
};

export type NamedEntityResolvers<
ContextType = any,
ContextType = MercuriusContext,
ParentType extends ResolversParentTypes['NamedEntity'] = ResolversParentTypes['NamedEntity']
> = {
resolveType: TypeResolveFn<'Human', ParentType, ContextType>;
Expand All @@ -325,7 +326,7 @@ export interface ExampleScalarScalarConfig
}

export type QueryResolvers<
ContextType = any,
ContextType = MercuriusContext,
ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']
> = {
simpleString?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
Expand Down Expand Up @@ -386,7 +387,7 @@ export type QueryResolvers<
};

export type MutationResolvers<
ContextType = any,
ContextType = MercuriusContext,
ParentType extends ResolversParentTypes['Mutation'] = ResolversParentTypes['Mutation']
> = {
increment?: Resolver<
Expand All @@ -398,7 +399,7 @@ export type MutationResolvers<
};

export type HumanResolvers<
ContextType = any,
ContextType = MercuriusContext,
ParentType extends ResolversParentTypes['Human'] = ResolversParentTypes['Human']
> = {
name?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
Expand All @@ -425,7 +426,7 @@ export type HumanResolvers<
};

export type AResolvers<
ContextType = any,
ContextType = MercuriusContext,
ParentType extends ResolversParentTypes['A'] = ResolversParentTypes['A']
> = {
a?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
Expand All @@ -440,7 +441,7 @@ export type AResolvers<
};

export type BResolvers<
ContextType = any,
ContextType = MercuriusContext,
ParentType extends ResolversParentTypes['B'] = ResolversParentTypes['B']
> = {
b?: Resolver<ResolversTypes['Int'], ParentType, ContextType>;
Expand All @@ -455,7 +456,7 @@ export type BResolvers<
};

export type CResolvers<
ContextType = any,
ContextType = MercuriusContext,
ParentType extends ResolversParentTypes['C'] = ResolversParentTypes['C']
> = {
c?: Resolver<ResolversTypes['GreetingsEnum'], ParentType, ContextType>;
Expand All @@ -464,13 +465,13 @@ export type CResolvers<
};

export type TestUnionResolvers<
ContextType = any,
ContextType = MercuriusContext,
ParentType extends ResolversParentTypes['TestUnion'] = ResolversParentTypes['TestUnion']
> = {
resolveType: TypeResolveFn<'A' | 'B' | 'C', ParentType, ContextType>;
};

export type Resolvers<ContextType = any> = {
export type Resolvers<ContextType = MercuriusContext> = {
NamedEntity?: NamedEntityResolvers<ContextType>;
ExampleScalar?: GraphQLScalarType;
Query?: QueryResolvers<ContextType>;
Expand All @@ -486,7 +487,7 @@ export type Resolvers<ContextType = any> = {
* @deprecated
* Use "Resolvers" root object instead. If you wish to get "IResolvers", add "typesPrefix: I" to your config.
*/
export type IResolvers<ContextType = any> = Resolvers<ContextType>;
export type IResolvers<ContextType = MercuriusContext> = Resolvers<ContextType>;

type Loader<TReturn, TObj, TParams, TContext> = (
queries: Array<{
Expand Down Expand Up @@ -578,10 +579,7 @@ export type multipleArgsQuery = { __typename?: 'Query' } & {
a2: { __typename?: 'Human' } & Pick<Human, 'name'>;
};

export const simpleStringDocument: DocumentNode<
simpleStringQuery,
simpleStringQueryVariables
> = {
export const simpleStringDocument = {
kind: 'Document',
definitions: [
{
Expand Down Expand Up @@ -645,11 +643,8 @@ export const simpleStringDocument: DocumentNode<
},
},
],
};
export const arrayObjectArgsDocument: DocumentNode<
arrayObjectArgsQuery,
arrayObjectArgsQueryVariables
> = {
} as unknown as DocumentNode<simpleStringQuery, simpleStringQueryVariables>;
export const arrayObjectArgsDocument = {
kind: 'Document',
definitions: [
{
Expand Down Expand Up @@ -703,11 +698,11 @@ export const arrayObjectArgsDocument: DocumentNode<
},
},
],
};
export const multipleArgsDocument: DocumentNode<
multipleArgsQuery,
multipleArgsQueryVariables
> = {
} as unknown as DocumentNode<
arrayObjectArgsQuery,
arrayObjectArgsQueryVariables
>;
export const multipleArgsDocument = {
kind: 'Document',
definitions: [
{
Expand Down Expand Up @@ -766,7 +761,7 @@ export const multipleArgsDocument: DocumentNode<
},
},
],
};
} as unknown as DocumentNode<multipleArgsQuery, multipleArgsQueryVariables>;
declare module 'mercurius' {
interface IResolvers
extends Resolvers<import('mercurius').MercuriusContext> {}
Expand Down
9 changes: 5 additions & 4 deletions internal/test-utils/test/_generated.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GraphQLResolveInfo } from 'graphql';
import type { GraphQLResolveInfo } from 'graphql';
import type { MercuriusContext } from 'mercurius';
export type Maybe<T> = T | null;
export type Exact<T extends { [key: string]: unknown }> = {
[K in keyof T]: T[K];
Expand Down Expand Up @@ -152,21 +153,21 @@ export type ResolversParentTypes = {
};

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

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

/**
* @deprecated
* Use "Resolvers" root object instead. If you wish to get "IResolvers", add "typesPrefix: I" to your config.
*/
export type IResolvers<ContextType = any> = Resolvers<ContextType>;
export type IResolvers<ContextType = MercuriusContext> = Resolvers<ContextType>;

export interface Loaders {}

Expand Down
9 changes: 5 additions & 4 deletions internal/test-utils/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ test('create test app with codegen', async () => {
encoding: 'utf-8',
})
).toMatchInlineSnapshot(`
"import { GraphQLResolveInfo } from 'graphql';
"import type { GraphQLResolveInfo } from 'graphql';
import type { MercuriusContext } from 'mercurius';
export type Maybe<T> = T | null;
export type Exact<T extends { [key: string]: unknown }> = {
[K in keyof T]: T[K];
Expand Down Expand Up @@ -188,21 +189,21 @@ test('create test app with codegen', async () => {
};
export type QueryResolvers<
ContextType = any,
ContextType = MercuriusContext,
ParentType extends ResolversParentTypes['Query'] = ResolversParentTypes['Query']
> = {
hello?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
};
export type Resolvers<ContextType = any> = {
export type Resolvers<ContextType = MercuriusContext> = {
Query?: QueryResolvers<ContextType>;
};
/**
* @deprecated
* Use \\"Resolvers\\" root object instead. If you wish to get \\"IResolvers\\", add \\"typesPrefix: I\\" to your config.
*/
export type IResolvers<ContextType = any> = Resolvers<ContextType>;
export type IResolvers<ContextType = MercuriusContext> = Resolvers<ContextType>;
export interface Loaders {}
Expand Down
72 changes: 20 additions & 52 deletions packages/cli/test/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,14 @@ test('basic functionality works', async () => {

const shouldBeIncluded = '// This should be included';

const {
schemaCode,
clientCode,
generatedSchema,
scalarsEnumsHash,
} = await generate(server.graphql.schema, {
preImport: `
const { schemaCode, clientCode, generatedSchema, scalarsEnumsHash } =
await generate(server.graphql.schema, {
preImport: `
${shouldBeIncluded}
`,
react: true,
subscriptions: true,
});
react: true,
subscriptions: true,
});

expect(schemaCode).toMatchInlineSnapshot(`
"/**
Expand Down Expand Up @@ -186,14 +182,8 @@ test('basic functionality works', async () => {
subscriptionsClient,
});
export const {
query,
mutation,
mutate,
subscription,
resolved,
refetch,
} = client;
export const { query, mutation, mutate, subscription, resolved, refetch } =
client;
export const {
graphql,
Expand Down Expand Up @@ -283,16 +273,12 @@ test('custom scalars works', async () => {

await isReady;

const {
schemaCode,
clientCode,
generatedSchema,
scalarsEnumsHash,
} = await generate(server.graphql.schema, {
scalarTypes: {
Custom: '"hello world"',
},
});
const { schemaCode, clientCode, generatedSchema, scalarsEnumsHash } =
await generate(server.graphql.schema, {
scalarTypes: {
Custom: '"hello world"',
},
});

expect(clientCode).toMatchInlineSnapshot(`
"/**
Expand Down Expand Up @@ -339,14 +325,8 @@ test('custom scalars works', async () => {
queryFetcher,
});
export const {
query,
mutation,
mutate,
subscription,
resolved,
refetch,
} = client;
export const { query, mutation, mutate, subscription, resolved, refetch } =
client;
export const {
graphql,
Expand Down Expand Up @@ -1243,14 +1223,8 @@ test('javascript output works', async () => {
subscriptionsClient,
});
export const {
query,
mutation,
mutate,
subscription,
resolved,
refetch,
} = client;
export const { query, mutation, mutate, subscription, resolved, refetch } =
client;
/**
* @type {import(\\"@pablosz/gqless-react\\").ReactClient<import(\\"./schema.generated\\").GeneratedSchema>}
Expand Down Expand Up @@ -1532,14 +1506,8 @@ test('ignoreArgs transform', async () => {
queryFetcher,
});
export const {
query,
mutation,
mutate,
subscription,
resolved,
refetch,
} = client;
export const { query, mutation, mutate, subscription, resolved, refetch } =
client;
export const {
graphql,
Expand Down
Loading

0 comments on commit b509295

Please sign in to comment.