mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
[#10500] update_users_me to graphql; added documentation for users/me update for both REST and graphql api (#10622)
Co-authored-by: rijkvanzanten <rijkvanzanten@me.com>
This commit is contained in:
committed by
GitHub
parent
517c70b838
commit
b9636e3243
@@ -1593,6 +1593,7 @@ export class GraphQLService {
|
||||
{
|
||||
CreateCollectionTypes,
|
||||
ReadCollectionTypes,
|
||||
UpdateCollectionTypes,
|
||||
DeleteCollectionTypes,
|
||||
}: {
|
||||
CreateCollectionTypes: Record<string, ObjectTypeComposer<any, any>>;
|
||||
@@ -2457,6 +2458,37 @@ export class GraphQLService {
|
||||
});
|
||||
}
|
||||
|
||||
if ('directus_users' in schema.update.collections) {
|
||||
schemaComposer.Mutation.addFields({
|
||||
update_users_me: {
|
||||
type: ReadCollectionTypes['directus_users'],
|
||||
args: {
|
||||
data: toInputObjectType(UpdateCollectionTypes['directus_users']),
|
||||
},
|
||||
resolve: async (_, args, __, info) => {
|
||||
if (!this.accountability?.user) return null;
|
||||
const service = new UsersService({
|
||||
schema: this.schema,
|
||||
accountability: this.accountability,
|
||||
});
|
||||
|
||||
await service.updateOne(this.accountability.user, args.data);
|
||||
|
||||
if ('directus_users' in ReadCollectionTypes) {
|
||||
const selections = this.replaceFragmentsInSelections(
|
||||
info.fieldNodes[0]?.selectionSet?.selections,
|
||||
info.fragments
|
||||
);
|
||||
const query = this.getQuery(args, selections || [], info.variableValues);
|
||||
|
||||
return await service.readOne(this.accountability.user, query);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if ('directus_activity' in schema.create.collections) {
|
||||
schemaComposer.Mutation.addFields({
|
||||
create_comment: {
|
||||
|
||||
Reference in New Issue
Block a user