mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Implement 'locationName', 'location' in 'CreateGroup', 'UpdateGroup', and 'Group' resolvers
This commit is contained in:
parent
9396a61ec0
commit
d32c137cff
@ -9,6 +9,7 @@ import Resolver, {
|
|||||||
convertObjectToCypherMapLiteral,
|
convertObjectToCypherMapLiteral,
|
||||||
} from './helpers/Resolver'
|
} from './helpers/Resolver'
|
||||||
import { mergeImage } from './images/images'
|
import { mergeImage } from './images/images'
|
||||||
|
import createOrUpdateLocations from './users/location'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
Query: {
|
Query: {
|
||||||
@ -135,7 +136,9 @@ export default {
|
|||||||
return group
|
return group
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
return await writeTxResultPromise
|
const group = await writeTxResultPromise
|
||||||
|
await createOrUpdateLocations(params.id, params.locationName, session)
|
||||||
|
return group
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code === 'Neo.ClientError.Schema.ConstraintValidationFailed')
|
if (error.code === 'Neo.ClientError.Schema.ConstraintValidationFailed')
|
||||||
throw new UserInputError('Group with this slug already exists!')
|
throw new UserInputError('Group with this slug already exists!')
|
||||||
@ -206,7 +209,9 @@ export default {
|
|||||||
return group
|
return group
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
return await writeTxResultPromise
|
const group = await writeTxResultPromise
|
||||||
|
await createOrUpdateLocations(params.id, params.locationName, session)
|
||||||
|
return group
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code === 'Neo.ClientError.Schema.ConstraintValidationFailed')
|
if (error.code === 'Neo.ClientError.Schema.ConstraintValidationFailed')
|
||||||
throw new UserInputError('Group with this slug already exists!')
|
throw new UserInputError('Group with this slug already exists!')
|
||||||
@ -300,11 +305,13 @@ export default {
|
|||||||
},
|
},
|
||||||
Group: {
|
Group: {
|
||||||
...Resolver('Group', {
|
...Resolver('Group', {
|
||||||
|
undefinedToNull: ['deleted', 'disabled', 'locationName', 'about'],
|
||||||
hasMany: {
|
hasMany: {
|
||||||
categories: '-[:CATEGORIZED]->(related:Category)',
|
categories: '-[:CATEGORIZED]->(related:Category)',
|
||||||
},
|
},
|
||||||
hasOne: {
|
hasOne: {
|
||||||
avatar: '-[:AVATAR_IMAGE]->(related:Image)',
|
avatar: '-[:AVATAR_IMAGE]->(related:Image)',
|
||||||
|
location: '-[:IS_IN]->(related:Location)',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|||||||
@ -42,7 +42,7 @@ export const createGroupMutation = gql`
|
|||||||
name
|
name
|
||||||
icon
|
icon
|
||||||
}
|
}
|
||||||
# locationName # test this as result
|
locationName # test this as result
|
||||||
myRole
|
myRole
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ export const updateGroupMutation = gql`
|
|||||||
icon
|
icon
|
||||||
}
|
}
|
||||||
# avatar # test this as result
|
# avatar # test this as result
|
||||||
# locationName # test this as result
|
locationName # test this as result
|
||||||
myRole
|
myRole
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,7 +155,7 @@ export const groupQuery = gql`
|
|||||||
avatar {
|
avatar {
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
# locationName # test this as result
|
locationName # test this as result
|
||||||
myRole
|
myRole
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user