Updating event works

This commit is contained in:
Amit Jakubowicz 2019-06-05 14:21:43 +02:00
parent 93531421fa
commit 33fbe6acf8
6 changed files with 27 additions and 10 deletions

View file

@ -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}`

View file

@ -10,8 +10,8 @@ interface Props {
const EditEvent = (props: Props) => (
<EditEventMutation>
{
(editEvent, { loading }) => (
<GetEventQuery skip={!props.eventId}>
(editEvent, { loading: editLoading }) => (
<GetEventQuery skip={!props.eventId} variables={{id: props.eventId}}>
{
({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,

View file

@ -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<Data, Variables> {

View file

@ -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",

View file

@ -41,6 +41,11 @@ type CalendarEvent {
status: EventStatus!
location: Location!
occurrences: [EventOccurrence]
meta: EventMeta
}
type EventMeta {
tags: [String]!
}
type EventOccurrence {

View file

@ -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()
}
}
}