remove argument directive

This commit is contained in:
Hongbo Wu
2024-05-29 11:02:35 +08:00
parent 95539948ff
commit e66a1374be
4 changed files with 12 additions and 5 deletions

View File

@ -4,7 +4,7 @@ schema {
subscription: SubscriptionRootType
}
directive @sanitize(allowedTags: [String], maxLength: Int, minLength: Int, pattern: String) on ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION
directive @sanitize(allowedTags: [String], maxLength: Int, minLength: Int, pattern: String) on INPUT_FIELD_DEFINITION
type AddDiscoverFeedError {
errorCodes: [AddDiscoverFeedErrorCode!]!

View File

@ -30,7 +30,6 @@ import {
SubscribeError,
SubscribeErrorCode,
SubscribeSuccess,
Subscription as SubscriptionReturnType,
SubscriptionError,
SubscriptionsError,
SubscriptionsErrorCode,
@ -500,6 +499,14 @@ export const subscriptionResolver = authorized<
SubscriptionError,
QuerySubscriptionArgs
>(async (_, { id }, { uid, log }) => {
if (!id) {
log.error('Missing subscription id')
return {
errorCodes: [ErrorCode.BadRequest],
}
}
const subscription = await findSubscriptionById(uid, id)
if (!subscription) {
log.error('Subscription not found', { id })

View File

@ -14,7 +14,7 @@ export class SanitizedString extends GraphQLScalarType {
) {
super({
// Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ as per graphql-js
name: `SanitizedString_${allowedTags}_${maxLength}_${pattern}`.replace(
name: `SanitizedString_${allowedTags}_${maxLength}_${minLength}_${pattern}`.replace(
/\W/g,
''
),

View File

@ -11,7 +11,7 @@ const schema = gql`
maxLength: Int
minLength: Int
pattern: String
) on INPUT_FIELD_DEFINITION | ARGUMENT_DEFINITION
) on INPUT_FIELD_DEFINITION
# default error code
enum ErrorCode {
@ -3385,7 +3385,7 @@ const schema = gql`
discoverFeeds: DiscoverFeedResult!
scanFeeds(input: ScanFeedsInput!): ScanFeedsResult!
home(first: Int, after: String): HomeResult!
subscription(id: ID! @sanitize(minLength: 1)): SubscriptionResult!
subscription(id: ID!): SubscriptionResult!
}
schema {