Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
Add tests to compile output of graphqlgen with flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Weakky committed Nov 10, 2018
1 parent 5505044 commit e76fb8e
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 188 deletions.
1 change: 1 addition & 0 deletions packages/graphqlgen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"@types/prettier": "1.13.2",
"@types/rimraf": "2.0.2",
"@types/yargs": "12.0.1",
"flow-bin": "^0.86.0",
"jest": "23.6.0",
"ts-jest": "23.10.4",
"ts-node": "7.0.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/graphqlgen/src/tests/fixtures/context/flow-types.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// @flow

interface Data {
export interface Data {
users: User[];
}

interface Context {
export interface Context {
data: Data;
}

interface User {
export interface User {
id: string;
}
38 changes: 19 additions & 19 deletions packages/graphqlgen/src/tests/fixtures/prisma/flow-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface Review {
checkIn: number;
cleanliness: number;
communication: number;
createdAt: undefined;
createdAt: string;
id: string;
location: number;
stars: number;
Expand Down Expand Up @@ -119,7 +119,7 @@ export interface Amenities {

export interface User {
bookings: any[];
createdAt: undefined;
createdAt: string;
email: string;
firstName: string;
hostingExperiences: any[];
Expand All @@ -136,30 +136,30 @@ export interface User {
responseRate: number | null;
responseTime: number | null;
sentMessages: any[];
updatedAt: undefined;
updatedAt: string;
}

export interface Booking {
id: string;
createdAt: undefined;
createdAt: string;
bookee: any;
place: any;
startDate: undefined;
endDate: undefined;
startDate: any;
endDate: any;
payment: any;
}

export interface Payment {
booking: any;
createdAt: undefined;
createdAt: string;
id: string;
paymentMethod: any;
serviceFee: number;
}

export interface PaymentAccount {
id: string;
createdAt: undefined;
createdAt: string;
type: any | null;
user: any;
payments: any[];
Expand All @@ -170,7 +170,7 @@ export interface PaymentAccount {
export interface PAYMENT_PROVIDER {}

export interface PaypalInformation {
createdAt: undefined;
createdAt: string;
email: string;
id: string;
paymentAccount: any;
Expand All @@ -179,7 +179,7 @@ export interface PaypalInformation {
export interface CreditCardInformation {
cardNumber: string;
country: string;
createdAt: undefined;
createdAt: string;
expiresOnMonth: number;
expiresOnYear: number;
firstName: string;
Expand All @@ -191,21 +191,21 @@ export interface CreditCardInformation {
}

export interface Notification {
createdAt: undefined;
createdAt: string;
id: string;
link: string;
readDate: undefined;
readDate: any;
type: any | null;
user: any;
}

export interface NOTIFICATION_TYPE {}

export interface Message {
createdAt: undefined;
deliveredAt: undefined;
createdAt: string;
deliveredAt: any;
id: string;
readAt: undefined;
readAt: any;
}

export interface Pricing {
Expand Down Expand Up @@ -242,21 +242,21 @@ export interface Policies {
checkInEndTime: number;
checkInStartTime: number;
checkoutTime: number;
createdAt: undefined;
createdAt: string;
id: string;
updatedAt: undefined;
updatedAt: string;
}

export interface HouseRules {
additionalRules: string | null;
createdAt: undefined;
createdAt: string;
id: string;
partiesAndEventsAllowed: boolean | null;
petsAllowed: boolean | null;
smokingAllowed: boolean | null;
suitableForChildren: boolean | null;
suitableForInfants: boolean | null;
updatedAt: undefined;
updatedAt: string;
}

export interface Reservation {
Expand Down
130 changes: 7 additions & 123 deletions packages/graphqlgen/src/tests/flow/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`basic enum 1`] = `
// Code generated by github.com/prisma/graphqlgen, DO NOT EDIT.
import type { GraphQLResolveInfo } from \\"graphql\\";
import type { User } from \\"../../../fixtures/enum/types-flow\\";
import type { User } from \\"../../fixtures/enum/types-flow\\";
type Context = any;
type EnumAnnotation = \\"EDITOR\\" | \\"COLLABORATOR\\";
Expand Down Expand Up @@ -159,124 +159,12 @@ export const resolvers: Resolvers = {
]
`;
exports[`basic scalar 1`] = `
"/* @flow */
// Code generated by github.com/prisma/graphqlgen, DO NOT EDIT.
import type { GraphQLResolveInfo } from \\"graphql\\";
import type { AddMemberPayload } from \\"../../../fixtures/scalar/flow-types\\";
type Context = any;
// Types for Mutation
export const Mutation_defaultResolvers = {};
export interface Mutation_AddMemberData {
email: string;
projects: string[];
}
export interface Mutation_Args_AddMember {
data: AddMemberData;
}
export type Mutation_AddMember_Resolver = (
parent: {},
args: Mutation_Args_AddMember,
ctx: Context,
info: GraphQLResolveInfo
) => AddMemberPayload | Promise<AddMemberPayload>;
export interface Mutation_Resolvers {
addMember: (
parent: {},
args: Mutation_Args_AddMember,
ctx: Context,
info: GraphQLResolveInfo
) => AddMemberPayload | Promise<AddMemberPayload>;
}
// Types for AddMemberPayload
export const AddMemberPayload_defaultResolvers = {
json: (parent: AddMemberPayload) => parent.json
};
export type AddMemberPayload_Json_Resolver = (
parent: AddMemberPayload,
args: {},
ctx: Context,
info: GraphQLResolveInfo
) => string | null | Promise<string | null>;
export interface AddMemberPayload_Resolvers {
json: (
parent: AddMemberPayload,
args: {},
ctx: Context,
info: GraphQLResolveInfo
) => string | null | Promise<string | null>;
}
export interface Resolvers {
Mutation: Mutation_Resolvers;
AddMemberPayload: AddMemberPayload_Resolvers;
}
"
`;
exports[`basic scalar 2`] = `
Array [
Object {
"code": "/* @flow */
import { AddMemberPayload_defaultResolvers } from \\"[TEMPLATE-INTERFACES-PATH]\\";
import type { AddMemberPayload_Resolvers } from \\"[TEMPLATE-INTERFACES-PATH]\\";
export const AddMemberPayload: AddMemberPayload_Resolvers = {
...AddMemberPayload_defaultResolvers
};
",
"force": false,
"path": "AddMemberPayload.js",
},
Object {
"code": "/* @flow */
import type { Mutation_Resolvers } from \\"[TEMPLATE-INTERFACES-PATH]\\";
export const Mutation: Mutation_Resolvers = {
addMember: (parent, args, ctx, info) => {
throw new Error(\\"Resolver not implemented\\");
}
};
",
"force": false,
"path": "Mutation.js",
},
Object {
"code": "// @flow
// This resolver file was scaffolded by github.com/prisma/graphqlgen, DO NOT EDIT.
// Please do not import this file directly but copy & paste to your application code.
import type { Resolvers } from \\"[TEMPLATE-INTERFACES-PATH]\\";
import { Mutation } from \\"./Mutation\\";
import { AddMemberPayload } from \\"./AddMemberPayload\\";
export const resolvers: Resolvers = {
Mutation,
AddMemberPayload
};
",
"force": false,
"path": "index.js",
},
]
`;
exports[`basic schema 1`] = `
"/* @flow */
// Code generated by github.com/prisma/graphqlgen, DO NOT EDIT.
import type { GraphQLResolveInfo } from \\"graphql\\";
import type { Number } from \\"../../../fixtures/basic/types-flow\\";
import type { Number } from \\"../../fixtures/basic/types-flow\\";
type Context = any;
// Types for Query
Expand Down Expand Up @@ -614,11 +502,7 @@ exports[`basic union 1`] = `
// Code generated by github.com/prisma/graphqlgen, DO NOT EDIT.
import type { GraphQLResolveInfo } from \\"graphql\\";
import type {
User,
Student,
Professor
} from \\"../../../fixtures/union/flow-types\\";
import type { User, Student, Professor } from \\"../../fixtures/union/flow-types\\";
type Context = any;
// Types for User
Expand Down Expand Up @@ -791,8 +675,8 @@ exports[`context 1`] = `
// Code generated by github.com/prisma/graphqlgen, DO NOT EDIT.
import type { GraphQLResolveInfo } from \\"graphql\\";
import type { User } from \\"../../../fixtures/context/flow-types\\";
import type { Context } from \\"../../../fixtures/context/flow-types\\";
import type { User } from \\"../../fixtures/context/flow-types\\";
import type { Context } from \\"../../fixtures/context/flow-types\\";
// Types for Query
export const Query_defaultResolvers = {};
Expand Down Expand Up @@ -894,7 +778,7 @@ exports[`defaultName 1`] = `
// Code generated by github.com/prisma/graphqlgen, DO NOT EDIT.
import type { GraphQLResolveInfo } from \\"graphql\\";
import type { NumberNode } from \\"../../../fixtures/defaultName/flow-types\\";
import type { NumberNode } from \\"../../fixtures/defaultName/flow-types\\";
type Context = any;
// Types for Query
Expand Down Expand Up @@ -1232,7 +1116,7 @@ exports[`subscription 1`] = `
// Code generated by github.com/prisma/graphqlgen, DO NOT EDIT.
import type { GraphQLResolveInfo } from \\"graphql\\";
import type { User } from \\"../../../fixtures/subscription/flow-types\\";
import type { User } from \\"../../fixtures/subscription/flow-types\\";
type Context = any;
// Types for Subscription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import type {
Message,
AuthPayload,
MutationResult
} from \\"../../../fixtures/prisma/flow-types\\";
} from \\"../../fixtures/prisma/flow-types\\";
type Context = any;

type PLACE_SIZES =
Expand Down
Loading

0 comments on commit e76fb8e

Please sign in to comment.