Repository: directus/directus
File: api/src/services/graphql/index.ts (TypeScript)

Code before:
		if ('directus_users' in schema.read.collections) {
			schemaComposer.Query.addFields({
				users_me: {
					type: ReadCollectionTypes['directus_users']!,
					resolve: async (_, args, __, info) => {
						if (!this.accountability?.user) return null;
						const service = new UsersService({ schema: this.schema, accountability: this.accountability });

						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);
					},
				},
			});
		}

		if ('directus_permissions' in schema.read.collections) {
			schemaComposer.Query.addFields({
				permissions_me: {
					type: schemaComposer.createScalarTC<CollectionAccess>({
						name: 'test',
						parseValue: (value: unknown) => value as CollectionAccess,
						serialize: (value) => value,
					}),
					resolve: async (_, _args, __, _info) => {
						if (!this.accountability?.user && !this.accountability?.role) return null;

						const result = await fetchAccountabilityCollectionAccess(this.accountability, {
							schema: this.schema,
							knex: getDatabase(),
						});

						return result;
					},
				},
			});
		}

		if ('directus_roles' in schema.read.collections) {
			schemaComposer.Query.addFields({
				roles_me: {
					type: ReadCollectionTypes['directus_roles']!.List,
					resolve: async (_, args, __, info) => {
						if (!this.accountability?.user && !this.accountability?.role) return null;

						const service = new RolesService({

Review comment (security):
Should this be something like
```suggestion
						name: 'permissions_me_type',
```
?

Code after:
		if ('directus_users' in schema.read.collections) {
			schemaComposer.Query.addFields({
				users_me: {
					type: ReadCollectionTypes['directus_users']!,
					resolve: async (_, args, __, info) => {
						if (!this.accountability?.user) return null;
						const service = new UsersService({ schema: this.schema, accountability: this.accountability });

						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);
					},
				},
			});
		}

		if ('directus_permissions' in schema.read.collections) {
			schemaComposer.Query.addFields({
				permissions_me: {
					type: schemaComposer.createScalarTC<CollectionAccess>({
						name: 'permissions_me_type',
						parseValue: (value: unknown) => value as CollectionAccess,
						serialize: (value) => value,
					}),
					resolve: async (_, _args, __, _info) => {
						if (!this.accountability?.user && !this.accountability?.role) return null;

						const result = await fetchAccountabilityCollectionAccess(this.accountability, {
							schema: this.schema,
							knex: getDatabase(),
						});

						return result;
					},
				},
			});
		}

		if ('directus_roles' in schema.read.collections) {
			schemaComposer.Query.addFields({
				roles_me: {
					type: ReadCollectionTypes['directus_roles']!.List,
					resolve: async (_, args, __, info) => {
						if (!this.accountability?.user && !this.accountability?.role) return null;

						const service = new RolesService({