mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
backend for export user data
This commit is contained in:
parent
21a9094a25
commit
a67b74cae0
@ -105,6 +105,7 @@ export default shield(
|
|||||||
blockedUsers: isAuthenticated,
|
blockedUsers: isAuthenticated,
|
||||||
notifications: isAuthenticated,
|
notifications: isAuthenticated,
|
||||||
Donations: isAuthenticated,
|
Donations: isAuthenticated,
|
||||||
|
userData: isAuthenticated,
|
||||||
},
|
},
|
||||||
Mutation: {
|
Mutation: {
|
||||||
'*': deny,
|
'*': deny,
|
||||||
|
|||||||
33
backend/src/schema/resolvers/userData.js
Normal file
33
backend/src/schema/resolvers/userData.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
import log from './helpers/databaseLogger'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
Query: {
|
||||||
|
userData: async (object, args, context, resolveInfo) => {
|
||||||
|
const id = context.user.id
|
||||||
|
const cypher = `
|
||||||
|
MATCH (u:User { id: $id })
|
||||||
|
WITH u AS user
|
||||||
|
MATCH (p:Post)
|
||||||
|
WHERE (p)<-[:COMMENTS]-(:Comment)<-[:WROTE]-(user)
|
||||||
|
OR (user)-[:WROTE]->(p)
|
||||||
|
RETURN { user: properties(user), posts: collect(properties(p)) }
|
||||||
|
AS result
|
||||||
|
`
|
||||||
|
const session = context.driver.session()
|
||||||
|
const resultPromise = session.readTransaction(async (transaction) => {
|
||||||
|
const transactionResponse = transaction.run(cypher, {
|
||||||
|
id,
|
||||||
|
})
|
||||||
|
return transactionResponse
|
||||||
|
})
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await resultPromise
|
||||||
|
log(result.records[0].get('result'))
|
||||||
|
return result.records[0].get('result')
|
||||||
|
} finally {
|
||||||
|
session.close()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
10
backend/src/schema/types/type/UserData.gql
Normal file
10
backend/src/schema/types/type/UserData.gql
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
type UserData {
|
||||||
|
user: User!
|
||||||
|
posts: [Post]
|
||||||
|
}
|
||||||
|
|
||||||
|
type Query {
|
||||||
|
userData(
|
||||||
|
id: ID
|
||||||
|
): UserData
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user