Skip to content

Commit

Permalink
Add supports for deprecated
Browse files Browse the repository at this point in the history
Signed-off-by: kyongsikC <sinnerr0@gmail.com>
  • Loading branch information
kschoi-wev authored and sinnerr0 committed Sep 30, 2023
1 parent fed12e8 commit 36d0ec8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/openapi-to-graphql/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,8 @@ function getFieldForOperation<TSource, TContext, TArgs extends object>(
fetch
})

const deprecationReason = operation.operation.deprecated ? 'No longer supported' : undefined

// Get resolver and subscribe function for Subscription fields
if (operation.operationType === GraphQLOperationType.Subscription) {
const responseSchemaName = operation.responseDefinition
Expand All @@ -977,6 +979,7 @@ function getFieldForOperation<TSource, TContext, TArgs extends object>(
resolve,
subscribe,
args,
deprecationReason,
description: operation.description
}

Expand All @@ -996,6 +999,7 @@ function getFieldForOperation<TSource, TContext, TArgs extends object>(
type,
resolve,
args,
deprecationReason,
description: operation.description
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/openapi-to-graphql/src/schema_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ function createFields<TSource, TContext, TArgs extends object>({
type: requiredProperty
? new GraphQLNonNull(objectType as GraphQLOutputType)
: (objectType as GraphQLOutputType),

deprecationReason: fieldSchema?.deprecated ? 'No longer supported' : undefined,
description:
typeof fieldSchema === 'object' ? fieldSchema.description : null
}
Expand Down Expand Up @@ -1305,6 +1305,7 @@ export function getArgs<TSource, TContext, TArgs extends object>({

args[saneName] = {
type: paramRequired ? new GraphQLNonNull(type) : type,
deprecationReason: parameter.deprecated ? 'No longer supported' : undefined,
description: parameter.description // Might be undefined
}
})
Expand Down
1 change: 1 addition & 0 deletions packages/openapi-to-graphql/src/types/oas3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type SchemaObject = {
anyOf?: (SchemaObject | ReferenceObject)[]
oneOf?: (SchemaObject | ReferenceObject)[]
not?: (SchemaObject | ReferenceObject)[]
deprecated?: boolean
}

export type ReferenceObject = {
Expand Down

0 comments on commit 36d0ec8

Please sign in to comment.