Fix TS Issues

This commit is contained in:
Amit Jakubowicz 2019-05-25 10:54:49 +02:00
parent 96ebc77452
commit ced32e8ad9
9 changed files with 34 additions and 244 deletions

228
@types/graphql.d.ts vendored
View file

@ -1,228 +0,0 @@
// tslint:disable
// graphql typescript definitions
declare namespace GQL {
interface IGraphQLResponseRoot {
data?: IQuery | IMutation;
errors?: Array<IGraphQLResponseError>;
}
interface IGraphQLResponseError {
/** Required for all errors */
message: string;
locations?: Array<IGraphQLResponseErrorLocation>;
/** 7.2.2 says 'GraphQL servers may provide additional entries to error' */
[propName: string]: any;
}
interface IGraphQLResponseErrorLocation {
line: number;
column: number;
}
interface IQuery {
__typename: 'Query';
me: IUser | null;
events: Array<ICalendarEvent | null> | null;
occurrences: Array<IEventOccurrence | null> | null;
}
interface IEventsOnQueryArguments {
filter: IEventsQueryFilter;
}
interface IOccurrencesOnQueryArguments {
filter: IOccurrencesQueryFilter;
}
interface IUser {
__typename: 'User';
name: string;
username: string;
email: string;
id: string;
}
interface IEventsQueryFilter {
owner?: string | null;
limit?: number | null;
from?: any | null;
to?: any | null;
categories?: Array<any | null> | null;
}
interface ICalendarEvent {
__typename: 'CalendarEvent';
id: string;
owner: IUser;
info: Array<IEventInformation | null>;
time: IEventTime;
status: any;
contact: Array<IEventContactPerson>;
location: ILocation;
occurrences: Array<IEventOccurrence | null> | null;
}
interface IEventInformation {
__typename: 'EventInformation';
language: string;
title: string;
description: string | null;
}
interface IEventTime {
__typename: 'EventTime';
timeZone: any | null;
start: any | null;
end: any | null;
recurrence: string | null;
exceptions: string | null;
}
interface IEventContactPerson {
__typename: 'EventContactPerson';
name: string;
languages: Array<any> | null;
contact: IContact | null;
}
interface IContact {
__typename: 'Contact';
email: string | null;
phone: string | null;
}
interface ILocation {
__typename: 'Location';
address: string | null;
name: string | null;
coordinate: IGeoCoordinate | null;
}
interface IGeoCoordinate {
__typename: 'GeoCoordinate';
lat: number | null;
lng: number | null;
}
interface IEventOccurrence {
__typename: 'EventOccurrence';
id: string;
event: ICalendarEvent;
start: string;
utcStart: string;
end: string;
utcEnd: string;
timeZone: string;
}
interface IOccurrencesQueryFilter {
from?: any | null;
to?: any | null;
timeZone?: any | null;
categories?: Array<any | null> | null;
limit?: number | null;
}
interface IMutation {
__typename: 'Mutation';
signup: Array<IError | null> | null;
signin: IUserSession;
requestInvite: boolean;
createEvent: ICalendarEvent | null;
}
interface ISignupOnMutationArguments {
input?: ISignupInput | null;
}
interface ISigninOnMutationArguments {
input?: ISigninInput | null;
}
interface IRequestInviteOnMutationArguments {
input?: IRequestInviteInput | null;
}
interface ICreateEventOnMutationArguments {
input: ICreateEventInput;
}
interface ISignupInput {
email: string;
username: string;
name: string;
}
interface IError {
__typename: 'Error';
path: string;
message: string;
}
interface ISigninInput {
hash: string;
}
interface IUserSession {
__typename: 'UserSession';
hash: string;
user: IUser;
ctime: any;
isValid: boolean;
}
interface IRequestInviteInput {
email: string;
}
interface ICreateEventInput {
time?: IEventTimeInput | null;
info?: Array<IEventInformationInput | null> | null;
location?: IEventLocationInput | null;
meta?: IEventMetaInput | null;
status: string;
contact: Array<IEventContactPersonInput>;
}
interface IEventTimeInput {
timeZone: any;
start: any;
end: any;
recurrence?: string | null;
}
interface IEventInformationInput {
language: string;
title: string;
description?: string | null;
}
interface IEventLocationInput {
address?: string | null;
name?: string | null;
coordinate?: IGeoCoordinateInput | null;
}
interface IGeoCoordinateInput {
lat?: number | null;
lng?: number | null;
}
interface IEventMetaInput {
tags?: Array<string | null> | null;
}
interface IEventContactPersonInput {
name: string;
languages?: Array<any> | null;
contact?: IEventContactInput | null;
}
interface IEventContactInput {
email?: string | null;
phone?: string | null;
}
}
// tslint:enable

30
@types/index.d.ts vendored
View file

@ -24,10 +24,15 @@ declare namespace GQL {
interface IQuery {
__typename: 'Query';
me: IUser | null;
event: ICalendarEvent | null;
events: Array<ICalendarEvent | null> | null;
occurrences: Array<IEventOccurrence | null> | null;
}
interface IEventOnQueryArguments {
id: string;
}
interface IEventsOnQueryArguments {
filter: IEventsQueryFilter;
}
@ -44,14 +49,6 @@ declare namespace GQL {
id: string;
}
interface IEventsQueryFilter {
owner?: string | null;
limit?: number | null;
from?: any | null;
to?: any | null;
categories?: Array<any | null> | null;
}
interface ICalendarEvent {
__typename: 'CalendarEvent';
id: string;
@ -117,6 +114,14 @@ declare namespace GQL {
timeZone: string;
}
interface IEventsQueryFilter {
owner?: string | null;
limit?: number | null;
from?: any | null;
to?: any | null;
categories?: Array<any | null> | null;
}
interface IOccurrencesQueryFilter {
from?: any | null;
to?: any | null;
@ -178,9 +183,9 @@ declare namespace GQL {
}
interface ICreateEventInput {
time?: IEventTimeInput | null;
info?: Array<IEventInformationInput | null> | null;
location?: IEventLocationInput | null;
time: IEventTimeInput;
info: Array<IEventInformationInput | null>;
location: IEventLocationInput;
meta?: IEventMetaInput | null;
status: string;
contact: Array<IEventContactPersonInput>;
@ -227,3 +232,6 @@ declare namespace GQL {
}
// tslint:enable
// tslint:enable

View file

@ -9,10 +9,9 @@ import CreateEvent from "../Event/CreateEvent";
const httpLink = new HttpLink({
uri: 'http://localhost:4000',
uri: '/graphql',
})
const graphqlClient = new ApolloClient({
connectToDevTools: true,
link: httpLink,

View file

@ -119,6 +119,7 @@ const EventForm = (props: Props) => (
({field}) => <input {...field} placeholder="Email to contact"/>
}
</Field>
<button type="submit">Create</button>
</Form>
)
}

View file

@ -10,6 +10,14 @@ const config: webpack.Configuration = {
devServer: {
historyApiFallback: true,
hot: true,
proxy: {
'/graphql': {
redirect: false,
changeOrigin: true,
target: `http://localhost:4000`,
}
}
},
module: {
rules: [
@ -28,7 +36,7 @@ const config: webpack.Configuration = {
}
} ]
},
devtool: '#@source-map',
devtool: '@source-map',
output: {
path: path.resolve(__dirname, './dist'),
filename: 'bundle.js'

View file

@ -1,6 +1,7 @@
import SessionManager, { SessionAlreadyValidatedError } from "./SessionManager"
import { User } from "./User.entity"
import { PostOffice } from "../post_office"
import {GQL} from "../../../@types"
interface Dependencies {
sendEmail: PostOffice

View file

@ -4,7 +4,7 @@ import {
EventOccurrence
} from "../Calendar/Event.entity"
import { Context, ResolverMap } from "../@types/graphql-utils"
import {GQL} from "../../../@types"
const resolvers: ResolverMap = {
Query: {
event: (_, req: GQL.IEventOnQueryArguments, context, info) => {

View file

@ -59,6 +59,7 @@ export const createServer = async (dependencies: Dependencies) => {
const ctx: Context = {
req: a.req
}
console.log('cookies: ', a.req.cookies.toString())
if (a.req && a.req.headers.authentication) {
const session = await Session.findOne({hash: a.req.headers.authentication as string})
if (session) {

View file

@ -18,7 +18,7 @@
"src"
],
"files": [
"../@types/graphql.d.ts", "../node_modules/@types/node/ts3.2/index.d.ts"
"../@types/index.d.ts", "../node_modules/@types/node/ts3.2/index.d.ts"
],
"exclude": [
"**/*.spec.ts", "node_modules", "__tests__"