Skip to content

Commit

Permalink
feat(testing): update @graphql-codegen/testing package + include co…
Browse files Browse the repository at this point in the history
…mmon resolvers testing helpers and fixtures (#8556)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
charlypoly and github-actions[bot] committed Nov 2, 2022
1 parent 5cd6d06 commit 64e553c
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 120 deletions.
5 changes: 5 additions & 0 deletions .changeset/@graphql-cli_codegen-8556-dependencies.md
@@ -0,0 +1,5 @@
---
"@graphql-cli/codegen": patch
---
dependencies updates:
- Updated dependency [`@graphql-codegen/cli@2.13.10` ↗︎](https://www.npmjs.com/package/@graphql-codegen/cli/v/2.13.10) (from `2.13.9`, in `dependencies`)
5 changes: 5 additions & 0 deletions .changeset/@graphql-codegen_cli-8556-dependencies.md
@@ -0,0 +1,5 @@
---
"@graphql-codegen/cli": patch
---
dependencies updates:
- Updated dependency [`@graphql-codegen/core@2.6.4` ↗︎](https://www.npmjs.com/package/@graphql-codegen/core/v/2.6.4) (from `2.6.3`, in `dependencies`)
5 changes: 5 additions & 0 deletions .changeset/@graphql-codegen_core-8556-dependencies.md
@@ -0,0 +1,5 @@
---
"@graphql-codegen/core": patch
---
dependencies updates:
- Updated dependency [`@graphql-tools/utils@9.0.0` ↗︎](https://www.npmjs.com/package/@graphql-tools/utils/v/9.0.0) (from `^8.8.0`, in `dependencies`)
9 changes: 7 additions & 2 deletions .changeset/config.json
Expand Up @@ -5,8 +5,13 @@
"access": "restricted",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": ["@graphql-codegen/testing", "website", "example-*"],
"changelog": ["@changesets/changelog-github", { "repo": "dotansimha/graphql-code-generator" }],
"ignore": ["website", "example-*"],
"changelog": [
"@changesets/changelog-github",
{
"repo": "dotansimha/graphql-code-generator"
}
],
"snapshot": {
"useCalculatedVersion": true,
"prereleaseTemplate": "{tag}-{datetime}-{commit}"
Expand Down
5 changes: 5 additions & 0 deletions .changeset/metal-ravens-juggle.md
@@ -0,0 +1,5 @@
---
'@graphql-codegen/testing': minor
---

`mockGraphQLServer`, resolvers common testing helpers and fixtures, typing updates
6 changes: 3 additions & 3 deletions packages/plugins/flow/resolvers/tests/flow-resolvers.spec.ts
@@ -1,7 +1,7 @@
import '@graphql-codegen/testing';
import { buildSchema } from 'graphql';
import { plugin } from '../src/index.js';
import { schema } from '../../../typescript/resolvers/tests/common.js';
import { resolversTestingSchema } from '@graphql-codegen/testing';
import { Types, mergeOutputs } from '@graphql-codegen/plugin-helpers';
import { ENUM_RESOLVERS_SIGNATURE } from '../src/visitor.js';

Expand Down Expand Up @@ -132,7 +132,7 @@ describe('Flow Resolvers Plugin', () => {
});

it('Should generate basic type resolvers', () => {
const result = plugin(schema, [], {}, { outputFile: '' });
const result = plugin(resolversTestingSchema, [], {}, { outputFile: '' });

expect(result).toMatchSnapshot();
});
Expand All @@ -156,7 +156,7 @@ describe('Flow Resolvers Plugin', () => {
});

it('Should generate ResolversParentTypes', () => {
const result = plugin(schema, [], {}, { outputFile: '' }) as Types.ComplexPluginOutput;
const result = plugin(resolversTestingSchema, [], {}, { outputFile: '' }) as Types.ComplexPluginOutput;

expect(result.content).toBeSimilarStringTo(`
/** Mapping between all available schema types and the resolvers parents */
Expand Down
28 changes: 14 additions & 14 deletions packages/plugins/flow/resolvers/tests/mapping.spec.ts
@@ -1,13 +1,13 @@
import '@graphql-codegen/testing';
import { schema } from '../../../typescript/resolvers/tests/common.js';
import { resolversTestingSchema } from '@graphql-codegen/testing';
import { plugin } from '../src/index.js';
import { buildSchema } from 'graphql';
import { validateFlow as validate } from '../../flow/tests/validate-flow.js';
import { Types, mergeOutputs } from '@graphql-codegen/plugin-helpers';

describe('ResolversTypes', () => {
it('Should build ResolversTypes object when there are no mappers', async () => {
const result = await plugin(schema, [], {}, { outputFile: '' });
const result = await plugin(resolversTestingSchema, [], {}, { outputFile: '' });

expect(result.content).toBeSimilarStringTo(`
export type ResolversTypes = {
Expand All @@ -30,7 +30,7 @@ describe('ResolversTypes', () => {

it('Should build ResolversTypes with simple mappers', async () => {
const result = (await plugin(
schema,
resolversTestingSchema,
[],
{
mappers: {
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('ResolversTypes', () => {

it('Should build ResolversTypes with defaultMapper set', async () => {
const result = (await plugin(
schema,
resolversTestingSchema,
[],
{
mappers: {
Expand Down Expand Up @@ -95,7 +95,7 @@ describe('ResolversTypes', () => {

it('Should build ResolversTypes with external mappers', async () => {
const result = (await plugin(
schema,
resolversTestingSchema,
[],
{
mappers: {
Expand Down Expand Up @@ -201,7 +201,7 @@ describe('ResolversTypes', () => {

it('Should generate basic type resolvers with external mappers', async () => {
const result = (await plugin(
schema,
resolversTestingSchema,
[],
{
mappers: {
Expand Down Expand Up @@ -283,7 +283,7 @@ describe('ResolversTypes', () => {

it('Should generate basic type resolvers with external mappers using same imported type', async () => {
const result = (await plugin(
schema,
resolversTestingSchema,
[],
{
mappers: {
Expand Down Expand Up @@ -366,7 +366,7 @@ describe('ResolversTypes', () => {
it('Should generate the correct resolvers when used with mappers with interfaces', async () => {
const spy = jest.spyOn(console, 'warn').mockImplementation();
const result = (await plugin(
schema,
resolversTestingSchema,
[],
{
mappers: {
Expand Down Expand Up @@ -448,7 +448,7 @@ describe('ResolversTypes', () => {

it('Should generate basic type resolvers with defaultMapper set to any', async () => {
const result = (await plugin(
schema,
resolversTestingSchema,
[],
{
defaultMapper: 'any',
Expand Down Expand Up @@ -526,7 +526,7 @@ describe('ResolversTypes', () => {

it('Should generate basic type resolvers with defaultMapper set to external identifier', async () => {
const result = (await plugin(
schema,
resolversTestingSchema,
[],
{
defaultMapper: './my-file#MyBaseType',
Expand Down Expand Up @@ -606,7 +606,7 @@ describe('ResolversTypes', () => {

it('Should replace using Omit when non-mapped type is pointing to mapped type', async () => {
const result = (await plugin(
schema,
resolversTestingSchema,
[],
{
mappers: {
Expand Down Expand Up @@ -638,7 +638,7 @@ describe('ResolversTypes', () => {

it('Should not replace using Omit when non-mapped type is pointing to mapped type', async () => {
const result = (await plugin(
schema,
resolversTestingSchema,
[],
{
mappers: {
Expand Down Expand Up @@ -670,7 +670,7 @@ describe('ResolversTypes', () => {

it('Should build ResolversTypes with defaultMapper set using {T}', async () => {
const result = (await plugin(
schema,
resolversTestingSchema,
[],
{
defaultMapper: '$Shape<{T}>',
Expand Down Expand Up @@ -699,7 +699,7 @@ describe('ResolversTypes', () => {

it('Should build ResolversTypes with defaultMapper set using {T} with external identifier', async () => {
const result = (await plugin(
schema,
resolversTestingSchema,
[],
{
defaultMapper: './my-wrapper#CustomPartial<{T}>',
Expand Down

0 comments on commit 64e553c

Please sign in to comment.