GQL Server running again

This commit is contained in:
Amit Jakubowicz 2019-02-22 12:23:19 +01:00
parent 2cdbd076fa
commit 1e45f9fb86
5 changed files with 89 additions and 71 deletions

7
graphql.config.json Normal file
View File

@ -0,0 +1,7 @@
{
"README_schema" : "Specifies how to load the GraphQL schema that completion, error highlighting, and documentation is based on in the IDE",
"schema": {
"README_file" : "Remove 'file' to use request url below. A relative or absolute path to the JSON from a schema introspection query, e.g. '{ data: ... }' or a .graphql/.graphqls file describing the schema using GraphQL Schema Language. Changes to the file are watched.",
"file": "./server/src/schema.graphql"
}
}

View File

@ -2,7 +2,7 @@
export type Maybe<T> = T | null;
export interface EventsQueryFilter {
count?: Maybe<number>;
limit?: Maybe<number>;
}
export interface SignupInput {
@ -24,6 +24,8 @@ export interface RequestInviteInput {
}
export interface CreateEventInput {
owner: string;
time?: Maybe<EventTimeInput>;
info?: Maybe<(Maybe<EventInformationInput>)[]>;
@ -31,7 +33,10 @@ export interface CreateEventInput {
location?: Maybe<EventLocationInput>;
meta?: Maybe<EventMetaInput>;
owner: string
status: string;
contact: EventContactPersonInput[];
}
export interface EventTimeInput {
@ -70,6 +75,14 @@ export interface EventMetaInput {
tags?: Maybe<(Maybe<string>)[]>;
}
export interface EventContactPersonInput {
name: string;
languages?: Maybe<Language[]>;
contact?: Maybe<Contact>;
}
export interface EventContactInput {
email?: Maybe<string>;
@ -128,7 +141,7 @@ export interface CalendarEvent {
owner: User;
info: EventInformation[];
info: (Maybe<EventInformation>)[];
time: EventTime;
@ -227,6 +240,8 @@ export interface RequestInviteMutationArgs {
}
export interface CreateEventMutationArgs {
input?: Maybe<CreateEventInput>;
foo?: Maybe<string>;
}
import { ObjectID } from "mongodb";
@ -242,11 +257,11 @@ export interface UserDbObject {
export interface CalendarEventDbObject {
_id: ObjectID;
owner: ObjectID;
info: Maybe<(Maybe<EventInformationDbObject>)[]>;
time: Maybe<EventTimeDbObject>;
info: (Maybe<EventInformationDbObject>)[];
time: EventTime;
status: EventStatus;
contact: Maybe<EventContactPersonDbObject[]>;
location: Maybe<Location>;
contact: EventContactPersonDbObject[];
location: LocationDbObject;
}
export interface EventInformationDbObject {
@ -255,28 +270,10 @@ export interface EventInformationDbObject {
description: Maybe<string>;
}
export interface EventTimeDbObject {
timeZone: Maybe<TimeZone>;
start: Maybe<Timestamp>;
end: Maybe<Timestamp>;
recurrence: Maybe<string>;
exceptions: Maybe<string>;
}
export interface EventContactPersonDbObject {
name: string;
languages: Maybe<Language[]>;
contact: Maybe<ContactDbObject>;
}
export interface ContactDbObject {
email: Maybe<string>;
phone: Maybe<string>;
}
export interface GeoCoordinateDbObject {
lat: Maybe<number>;
lng: Maybe<number>;
languages: Maybe<LanguageDbObject[]>;
contact: Maybe<Contact>;
}
export interface UserSessionDbObject {
@ -413,19 +410,15 @@ export namespace CalendarEventResolvers {
owner?: OwnerResolver<User, TypeParent, Context>;
info?: InfoResolver<
Maybe<(Maybe<EventInformation>)[]>,
TypeParent,
Context
>;
info?: InfoResolver<(Maybe<EventInformation>)[], TypeParent, Context>;
time?: TimeResolver<Maybe<EventTime>, TypeParent, Context>;
time?: TimeResolver<EventTime, TypeParent, Context>;
status?: StatusResolver<EventStatus, TypeParent, Context>;
contact?: ContactResolver<Maybe<EventContactPerson[]>, TypeParent, Context>;
contact?: ContactResolver<EventContactPerson[], TypeParent, Context>;
location?: LocationResolver<Maybe<Location>, TypeParent, Context>;
location?: LocationResolver<Location, TypeParent, Context>;
}
export type IdResolver<
@ -439,12 +432,12 @@ export namespace CalendarEventResolvers {
Context = {}
> = Resolver<R, Parent, Context>;
export type InfoResolver<
R = Maybe<(Maybe<EventInformation>)[]>,
R = (Maybe<EventInformation>)[],
Parent = CalendarEvent,
Context = {}
> = Resolver<R, Parent, Context>;
export type TimeResolver<
R = Maybe<EventTime>,
R = EventTime,
Parent = CalendarEvent,
Context = {}
> = Resolver<R, Parent, Context>;
@ -454,12 +447,12 @@ export namespace CalendarEventResolvers {
Context = {}
> = Resolver<R, Parent, Context>;
export type ContactResolver<
R = Maybe<EventContactPerson[]>,
R = EventContactPerson[],
Parent = CalendarEvent,
Context = {}
> = Resolver<R, Parent, Context>;
export type LocationResolver<
R = Maybe<Location>,
R = Location,
Parent = CalendarEvent,
Context = {}
> = Resolver<R, Parent, Context>;
@ -672,6 +665,8 @@ export namespace MutationResolvers {
> = Resolver<R, Parent, Context, CreateEventArgs>;
export interface CreateEventArgs {
input?: Maybe<CreateEventInput>;
foo?: Maybe<string>;
}
}

View File

@ -1,7 +1,7 @@
import EventManager from './EventManager'
import CalendarManager from "../Calendar/CalendarManager";
import CreateEventResolver = MutationResolvers.CreateEventResolver;
import {MutationResolvers} from "../@types";
import {CalendarEventResolvers, MutationResolvers} from "../@types";
import CreateEventArgs = MutationResolvers.CreateEventArgs;
export default class EventsResolvers {
@ -19,6 +19,12 @@ export default class EventsResolvers {
},
}
Event = {
owner: async (event, args, context, info) => {
}
}
Mutation: {
createEvent: CreateEventResolver
} = {

View File

@ -9,6 +9,7 @@ import EventsResolvers from './Events/eventsResolvers'
import {importSchema} from 'graphql-import';
import AuthResolvers from "./Auth/authResolvers";
import { DIRECTIVES } from 'graphql-codegen-typescript-mongodb';
import {readFileSync} from "fs";
interface Dependencies {
repository: Repository,
@ -44,10 +45,13 @@ export default class GraphQLInterface {
userManager: this.userManager
})
const typeDefs = importSchema(__dirname + '/schema.graphql');
const typeDefs = readFileSync(__dirname + '/schema.graphql', 'utf8');
const schema = makeExecutableSchema({
typeDefs,
typeDefs: [
DIRECTIVES,
typeDefs
],
resolvers: {
Query: {
...this.resolvers.Query,

View File

@ -1,18 +1,18 @@
type User {
firstName: String!
lastName: String
username: String!
email: String!
id: ID!
type User @entity {
firstName: String! @column
lastName: String @column
username: String! @column
email: String! @column
id: ID! @id
}
scalar Date
type UserSession {
hash: String!
user: User!
ctime: Date!
isValid: Boolean!
type UserSession @entity {
hash: String! @column
user: User! @link
ctime: Date! @column
isValid: Boolean! @column
}
input SignupInput {
@ -35,14 +35,14 @@ input RequestInviteInput {
# ------
type CalendarEvent {
id: ID!
owner: User!
info: [EventInformation]!
time: EventTime!
status: EventStatus!
contact: [EventContactPerson!]!
location: Location!
type CalendarEvent @entity {
id: ID! @id
owner: User! @link
info: [EventInformation]! @embedded
time: EventTime! @column
status: EventStatus! @column
contact: [EventContactPerson!]! @embedded
location: Location! @embedded
}
type Location {
@ -77,19 +77,19 @@ scalar EventStatus
scalar Language
# Event information for presentation
type EventInformation {
language: String!
title: String!
description: String
type EventInformation @entity {
language: String! @column
title: String! @column
description: String @column
}
type EventContactPerson {
name: String!
languages: [Language!]
contact: Contact
type EventContactPerson @entity {
name: String! @column
languages: [Language!] @embedded
contact: Contact @column
}
type Contact {
type Contact {
email: String
phone: String
}
@ -131,6 +131,12 @@ input EventMetaInput {
tags: [String]
}
input EventContactPersonInput {
name: String!
languages: [Language!]
contact: EventContactInput
}
input CreateEventInput {
owner: ID!
time: EventTimeInput
@ -138,7 +144,7 @@ input CreateEventInput {
location: EventLocationInput
meta: EventMetaInput
status: String!
contact: [ContactPerson!]!
contact: [EventContactPersonInput!]!
}
type Mutation {