mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-01-20 20:01:25 +00:00
parent
a5c87e0cd5
commit
6340efbfc5
@ -1,4 +1,5 @@
|
||||
import createOrUpdateLocations from './nodes/locations'
|
||||
import find from 'lodash/find'
|
||||
|
||||
export default {
|
||||
Mutation: {
|
||||
@ -12,5 +13,28 @@ export default {
|
||||
await createOrUpdateLocations(args.id, args.locationName, context.driver)
|
||||
return result
|
||||
}
|
||||
},
|
||||
Query: {
|
||||
User: async (resolve, root, args, context, info) => {
|
||||
let isIdPresent
|
||||
let removeIdFromResult
|
||||
try {
|
||||
isIdPresent = find(info.fieldNodes[0].selectionSet.selections, item => item.name.value === 'id')
|
||||
if (!isIdPresent) {
|
||||
// add id to request as the user did not ask but we need it
|
||||
info.fieldNodes[0].selectionSet.selections.unshift({
|
||||
kind: 'Field',
|
||||
name: { kind: 'Name', value: 'id' }
|
||||
})
|
||||
removeIdFromResult = true
|
||||
}
|
||||
} catch(err) {}
|
||||
const result = await resolve(root, args, context, info)
|
||||
if (!isIdPresent && removeIdFromResult) {
|
||||
// remove id if the user did not ask for it
|
||||
info.fieldNodes[0].selectionSet.selections.shift()
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user