From 33fbe6acf84922d5a33ff48fca43817a2a30265d Mon Sep 17 00:00:00 2001 From: Amit Jakubowicz Date: Wed, 5 Jun 2019 14:21:43 +0200 Subject: [PATCH] Updating event works --- client/App/App.tsx | 1 + client/Event/EditEvent.tsx | 6 +++--- client/Event/GetEventQuery.ts | 9 ++++++++- client/webpack.config.ts | 3 ++- schema.graphql | 5 +++++ server/src/Events/eventsResolvers.ts | 13 ++++++++----- 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/client/App/App.tsx b/client/App/App.tsx index 50e37ce..4b73180 100644 --- a/client/App/App.tsx +++ b/client/App/App.tsx @@ -23,6 +23,7 @@ const graphqlClient = new ApolloClient({ connectToDevTools: true, link: httpLink, cache: new InMemoryCache({ + addTypename: false, dataIdFromObject: (o: IdGetterObj) => { if (o.id && o.__typename) { return `${o.__typename}_${o.id}` diff --git a/client/Event/EditEvent.tsx b/client/Event/EditEvent.tsx index 77715f4..444068f 100644 --- a/client/Event/EditEvent.tsx +++ b/client/Event/EditEvent.tsx @@ -10,8 +10,8 @@ interface Props { const EditEvent = (props: Props) => ( { - (editEvent, { loading }) => ( - + (editEvent, { loading: editLoading }) => ( + { ({data, error, loading}) => { if (loading) { @@ -34,7 +34,7 @@ const EditEvent = (props: Props) => ( }) }} values={{ - contact: data.event.contact, + meta: data.event.meta, time: data.event.time, location: data.event.location, info: data.event.info, diff --git a/client/Event/GetEventQuery.ts b/client/Event/GetEventQuery.ts index bfadfd4..9307f16 100644 --- a/client/Event/GetEventQuery.ts +++ b/client/Event/GetEventQuery.ts @@ -21,6 +21,9 @@ export const EventFragment = gql` recurrence } status + meta { + tags + } } ` @@ -45,6 +48,9 @@ export interface ContactData { languages: string[] name: string } +export interface EventMetaData { + tags: string[] +} export interface EventData { id: string @@ -56,6 +62,7 @@ export interface EventData { } time: EventTimeData status: EventStatus + meta: EventMetaData } interface Data { @@ -72,7 +79,7 @@ const query = gql` ` interface Variables { - id: number + id: string } export default class GetEventQuery extends Query { diff --git a/client/webpack.config.ts b/client/webpack.config.ts index a37a539..7c56df1 100644 --- a/client/webpack.config.ts +++ b/client/webpack.config.ts @@ -39,7 +39,8 @@ const config: webpack.Configuration = { devtool: '@source-map', output: { path: path.resolve(__dirname, './dist'), - filename: 'bundle.js' + filename: 'bundle.js', + publicPath: '/' }, plugins: [new HtmlWebpackPlugin({ title: "blabla", diff --git a/schema.graphql b/schema.graphql index c0ee47c..6aba84b 100644 --- a/schema.graphql +++ b/schema.graphql @@ -41,6 +41,11 @@ type CalendarEvent { status: EventStatus! location: Location! occurrences: [EventOccurrence] + meta: EventMeta +} + +type EventMeta { + tags: [String]! } type EventOccurrence { diff --git a/server/src/Events/eventsResolvers.ts b/server/src/Events/eventsResolvers.ts index 7abb09d..a26998a 100644 --- a/server/src/Events/eventsResolvers.ts +++ b/server/src/Events/eventsResolvers.ts @@ -87,7 +87,6 @@ const resolvers: ResolverMap = { _, { input }: GQL.IUpdateEventOnMutationArguments, context: Context, - info ) => { const {id, ...fields} = input @@ -116,12 +115,16 @@ const resolvers: ResolverMap = { }) ) } - if (info.location) { - event.location = info.location + if (input.location) { + event.location = input.location } - if (info.meta) { - event.meta = info.meta + if (input.meta) { + event.meta = input.meta } + if (input.location) { + event.location = input.location + } + return event.save() } } }