chore: completed mutation to create a SharedRequest
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Args, ID, Resolver, Query } from '@nestjs/graphql';
|
||||
import { Args, ID, Resolver, Query, Mutation } from '@nestjs/graphql';
|
||||
import { SharedRequest } from './shared-requests.model';
|
||||
import { GqlThrottlerGuard } from 'src/guards/gql-throttler.guard';
|
||||
import { UseGuards } from '@nestjs/common';
|
||||
@@ -8,6 +8,8 @@ import { PubSubService } from 'src/pubsub/pubsub.service';
|
||||
import * as E from 'fp-ts/Either';
|
||||
import { GqlAuthGuard } from 'src/guards/gql-auth.guard';
|
||||
import { throwErr } from 'src/utils';
|
||||
import { GqlUser } from 'src/decorators/gql-user.decorator';
|
||||
import { AuthUser } from 'src/types/AuthUser';
|
||||
|
||||
@UseGuards(GqlThrottlerGuard)
|
||||
@Resolver(() => SharedRequest)
|
||||
@@ -36,4 +38,33 @@ export class SharedRequestResolver {
|
||||
if (E.isLeft(result)) throwErr(result.left);
|
||||
return result.right;
|
||||
}
|
||||
|
||||
/* Mutations */
|
||||
@Mutation(() => SharedRequest, {
|
||||
description: 'Create a shared-request for the given request.',
|
||||
})
|
||||
@UseGuards(GqlAuthGuard)
|
||||
async createSharedRequest(
|
||||
@GqlUser() user: AuthUser,
|
||||
@Args({
|
||||
name: 'request',
|
||||
description: 'JSON string of the request object',
|
||||
})
|
||||
request: string,
|
||||
@Args({
|
||||
name: 'properties',
|
||||
description: 'JSON string of the properties of the embed',
|
||||
nullable: true,
|
||||
})
|
||||
properties: string,
|
||||
) {
|
||||
const result = await this.sharedRequestService.createSharedRequest(
|
||||
request,
|
||||
properties,
|
||||
user,
|
||||
);
|
||||
|
||||
if (E.isLeft(result)) throwErr(result.left);
|
||||
return result.right;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user