mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
29 lines
872 B
JavaScript
29 lines
872 B
JavaScript
import cloneDeep from 'lodash/cloneDeep'
|
|
|
|
const includeId = async (resolve, root, args, context, resolveInfo) => {
|
|
// Keeping the graphql resolveInfo untouched ensures that we don't add the
|
|
// following attributes to the result set returned to the graphQL client.
|
|
// We only want to pass these attributes to our resolver for internal
|
|
// purposes e.g. authorization.
|
|
const copy = cloneDeep(resolveInfo)
|
|
|
|
copy.fieldNodes[0].selectionSet.selections.unshift({
|
|
kind: 'Field',
|
|
name: { kind: 'Name', value: 'id' }
|
|
})
|
|
return resolve(root, args, context, copy)
|
|
}
|
|
|
|
export default {
|
|
Query: {
|
|
User: (resolve, root, args, context, info) => {
|
|
return includeId(resolve, root, args, context, info)
|
|
}
|
|
},
|
|
Mutation: {
|
|
CreatePost: (resolve, root, args, context, info) => {
|
|
return includeId(resolve, root, args, context, info)
|
|
}
|
|
}
|
|
}
|