nestjs / graphql

GraphQL (TypeScript) module for Nest framework (node.js) 🍷
https://docs.nestjs.com/graphql/quick-start
MIT License
1.45k stars 394 forks source link

@Extensions decorator don't work on @Field included in @InputType #3328

Open Vittorio1970 opened 1 week ago

Vittorio1970 commented 1 week ago

Is there an existing issue that is already proposing this?

Is your feature request related to a problem? Please describe it

@ObjectType()

export class SampleOutput {
  **@Extensions({ key: 'Value present in extensions member' })**
  @Field({
    nullable: true,
  })
  errorMessage: string;
}

Result

{
  name: "errorMessage",
  description: undefined,
  type: { ........ },
  args: [],
  resolve: (source, args, contextValue, info) => { ..... },
  subscribe: undefined,
  deprecationReason: undefined,
  extensions: {
    complexity: undefined,
    **key: "Value present in fieldconfig",**
  },
  astNode: undefined,
}

@InputType()

export class SampleInput {
  @Extensions({ key: 'Value not present in field config' })
  @Field({
    nullable: false,
    defaultValue: false,
  })
  forceCreation: boolean;
}

Result

{
  name: "forceCreation",
  description: undefined,
  type: { .... },
  defaultValue: false,
  deprecationReason: undefined,
  **extensions: {
  },**
  astNode: undefined,
}

Describe the solution you'd like

Same behavior for fields included in both InputType and ObjectType

Teachability, documentation, adoption, migration strategy

.

What is the motivation / use case for changing the behavior?

.

kamilmysliwiec commented 12 hours ago

Please provide a minimum reproduction repository (Git repository/StackBlitz/CodeSandbox project).

Vittorio1970 commented 7 hours ago

https://codesandbox.io/p/devbox/friendly-newton-lnjrc3

Info from the schema handler

[Object: null prototype] { OtypeMember: { name: 'OtypeMember', description: undefined, type: GraphQLScalarType { name: 'String', description: 'TheStringscalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.', specifiedByURL: undefined, serialize: [Function: serialize], parseValue: [Function: parseValue], parseLiteral: [Function: parseLiteral], extensions: [Object: null prototype] {}, astNode: undefined, extensionASTNodes: [] }, args: [], resolve: [Function: rootFieldResolver], subscribe: undefined, deprecationReason: undefined, extensions: [Object: null prototype] { complexity: undefined, key: 'value' }, astNode: undefined } } [Object: null prototype] { ItypeMember: { name: 'ItypeMember', description: undefined, type: GraphQLScalarType { name: 'String', description: 'TheStringscalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.', specifiedByURL: undefined, serialize: [Function: serialize], parseValue: [Function: parseValue], parseLiteral: [Function: parseLiteral], extensions: [Object: null prototype] {}, astNode: undefined, extensionASTNodes: [] }, defaultValue: undefined, deprecationReason: undefined, extensions: [Object: null prototype] {}, astNode: undefined } }