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

fix(interface types): use ? in place of | null #26

Merged
merged 2 commits into from
Aug 20, 2018
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-resolver-codegen",
"version": "0.1.4",
"version": "0.1.5",
"description": "Generate resolver types based on a GraphQL Schema",
"main": "dist/index.js",
"bin": {
Expand Down
5 changes: 4 additions & 1 deletion src/generators/ts-scaffolder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ export function generate(args: GenerateArgs): CodeFileLike[] {
${type.fields
.map(
field => `
${field.name}: ${printFieldLikeType(field, false)}
${field.name}${!field.type.isRequired ? "?" : ""}: ${printFieldLikeType(
field,
false
).replace("| null", "")}
`
)
.join(";")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ Array [
import { Types } from \\"./types\\";

export interface NumberRoot {
id: string | null;
value: number | null;
id?: string;
value?: number;
}

export const Number: INumber.Resolver<Types> = {
Expand Down Expand Up @@ -177,7 +177,7 @@ export const Student: IStudent.Resolver<Types> = {
import { Types } from \\"./types\\";

export interface ProfessorRoot {
degree: string | null;
degree?: string;
}

export const Professor: IProfessor.Resolver<Types> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ import { PictureRoot } from \\"./Picture\\";

export interface HomeRoot {
id: string;
name: string | null;
name?: string;
description: string;
numRatings: number;
avgRating: number | null;
avgRating?: number;
pictures: PictureRoot[];
perNight: number;
}
Expand Down Expand Up @@ -142,7 +142,7 @@ import { PictureRoot } from \\"./Picture\\";

export interface ExperienceRoot {
id: string;
category: ExperienceCategoryRoot | null;
category?: ExperienceCategoryRoot;
title: string;
location: LocationRoot;
pricePerPerson: number;
Expand Down Expand Up @@ -209,7 +209,7 @@ export interface NeighbourhoodRoot {
id: string;
name: string;
slug: string;
homePreview: PictureRoot | null;
homePreview?: PictureRoot;
city: CityRoot;
featured: boolean;
popularity: number;
Expand All @@ -236,8 +236,8 @@ export interface LocationRoot {
id: string;
lat: number;
lng: number;
address: string | null;
directions: string | null;
address?: string;
directions?: string;
}

export const Location: ILocation.Resolver<Types> = {
Expand Down Expand Up @@ -294,7 +294,7 @@ export interface ExperienceCategoryRoot {
id: string;
mainColor: string;
name: string;
experience: ExperienceRoot | null;
experience?: ExperienceRoot;
}

export const ExperienceCategory: IExperienceCategory.Resolver<Types> = {
Expand Down Expand Up @@ -334,10 +334,10 @@ export interface UserRoot {
ownedPlaces: PlaceRoot[];
paymentAccount: PaymentAccountRoot[];
phone: string;
profilePicture: PictureRoot | null;
profilePicture?: PictureRoot;
receivedMessages: MessageRoot[];
responseRate: number | null;
responseTime: number | null;
responseRate?: number;
responseTime?: number;
sentMessages: MessageRoot[];
updatedAt: DateTimeRoot;
token: string;
Expand Down Expand Up @@ -382,11 +382,11 @@ import { CreditCardInformationRoot } from \\"./CreditCardInformation\\";
export interface PaymentAccountRoot {
id: string;
createdAt: DateTimeRoot;
type: PAYMENT_PROVIDERRoot | null;
type?: PAYMENT_PROVIDERRoot;
user: UserRoot;
payments: PaymentRoot[];
paypal: PaypalInformationRoot | null;
creditcard: CreditCardInformationRoot | null;
paypal?: PaypalInformationRoot;
creditcard?: CreditCardInformationRoot;
}

export const PaymentAccount: IPaymentAccount.Resolver<Types> = {
Expand Down Expand Up @@ -420,8 +420,8 @@ import { PictureRoot } from \\"./Picture\\";

export interface PlaceRoot {
id: string;
name: string | null;
size: PLACE_SIZESRoot | null;
name?: string;
size?: PLACE_SIZESRoot;
shortDescription: string;
description: string;
slug: string;
Expand All @@ -435,9 +435,9 @@ export interface PlaceRoot {
pricing: PricingRoot;
location: LocationRoot;
views: PlaceViewsRoot;
guestRequirements: GuestRequirementsRoot | null;
policies: PoliciesRoot | null;
houseRules: HouseRulesRoot | null;
guestRequirements?: GuestRequirementsRoot;
policies?: PoliciesRoot;
houseRules?: HouseRulesRoot;
bookings: BookingRoot[];
pictures: PictureRoot[];
popularity: number;
Expand Down Expand Up @@ -514,7 +514,7 @@ export interface NotificationRoot {
id: string;
link: string;
readDate: DateTimeRoot;
type: NOTIFICATION_TYPERoot | null;
type?: NOTIFICATION_TYPERoot;
user: UserRoot;
}

Expand Down Expand Up @@ -594,7 +594,7 @@ export interface CreditCardInformationRoot {
firstName: string;
id: string;
lastName: string;
paymentAccount: PaymentAccountRoot | null;
paymentAccount?: PaymentAccountRoot;
postalCode: string;
securityCode: string;
}
Expand Down Expand Up @@ -647,16 +647,16 @@ export interface PricingRoot {
averageMonthly: number;
averageWeekly: number;
basePrice: number;
cleaningFee: number | null;
currency: CURRENCYRoot | null;
extraGuests: number | null;
cleaningFee?: number;
currency?: CURRENCYRoot;
extraGuests?: number;
id: string;
monthlyDiscount: number | null;
monthlyDiscount?: number;
perNight: number;
securityDeposit: number | null;
securityDeposit?: number;
smartPricing: boolean;
weekendPricing: number | null;
weeklyDiscount: number | null;
weekendPricing?: number;
weeklyDiscount?: number;
}

export const Pricing: IPricing.Resolver<Types> = {
Expand Down Expand Up @@ -748,14 +748,14 @@ import { Types } from \\"./types\\";
import { DateTimeRoot } from \\"./DateTime\\";

export interface HouseRulesRoot {
additionalRules: string | null;
additionalRules?: string;
createdAt: DateTimeRoot;
id: string;
partiesAndEventsAllowed: boolean | null;
petsAllowed: boolean | null;
smokingAllowed: boolean | null;
suitableForChildren: boolean | null;
suitableForInfants: boolean | null;
partiesAndEventsAllowed?: boolean;
petsAllowed?: boolean;
smokingAllowed?: boolean;
suitableForChildren?: boolean;
suitableForInfants?: boolean;
updatedAt: DateTimeRoot;
}

Expand Down