mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-04-06 01:25:38 +00:00
* type for neo4j and neode * fix build * remove flakyness * wait for neode to install schema * remove flakyness * explain why we wait for a non-promise * refactor context missing change missing change * adjust test setup proper cleanup after test * lint fixes * fix failing test to use new context
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
import { getNeode } from '@db/neo4j'
|
|
|
|
import Resolver from './helpers/Resolver'
|
|
|
|
const neode = getNeode()
|
|
|
|
export default {
|
|
Mutation: {
|
|
CreateSocialMedia: async (_object, params, context, _resolveInfo) => {
|
|
const [user, socialMedia] = await Promise.all([
|
|
neode.find('User', context.user.id),
|
|
neode.create('SocialMedia', params),
|
|
])
|
|
await socialMedia.relateTo(user, 'ownedBy')
|
|
const response = await socialMedia.toJson()
|
|
|
|
return response
|
|
},
|
|
UpdateSocialMedia: async (_object, params, _context, _resolveInfo) => {
|
|
const socialMedia = await neode.find('SocialMedia', params.id)
|
|
await socialMedia.update({ url: params.url })
|
|
const response = await socialMedia.toJson()
|
|
|
|
return response
|
|
},
|
|
DeleteSocialMedia: async (_object, { id }, _context, _resolveInfo) => {
|
|
const socialMedia = await neode.find('SocialMedia', id)
|
|
if (!socialMedia) return null
|
|
await socialMedia.delete()
|
|
return socialMedia.toJson()
|
|
},
|
|
},
|
|
SocialMedia: Resolver('SocialMedia', {
|
|
idAttribute: 'url',
|
|
hasOne: {
|
|
ownedBy: '-[:OWNED_BY]->(related:User)',
|
|
},
|
|
}),
|
|
}
|