Input arguments being marked as `deprecated` in introspection when only the mutation is `deprecated`
- Linguagem predominante
- Go
- Estrelas
- 10.8k
- Forks
- 1.3k
- Merge médio
- 2d 36min
- PRs com merge (30d)
- 26
Descrição
I have a mutation that has been deprecated using the `@deprecated` directive. The input arguments are *not* marked as deprecated.
However, when I do introspection on this schema I get told that the input argument itself is deprecated. And it is deprecated for the same reason as the mutation itself. This causes GraphQL validation errors as a required argument cannot be marked as duplicated.
I'd expect this to not be marked as deprecated unless I explicitly added the `@deprecated` directive on the input.
Validation:
https://github.com/graphql/graphql-js/blob/9032db1e4e55052bead6936359ecc5592c817f64/src/type/validate.ts#L198
From what I can tell, this is the issue - we are using the deprecation directive of the Field (mutation) instead of the argument.
https://github.com/99designs/gqlgen/commit/6cb6e32c342b3997d287f9ecab6e14d22b9dcceb#diff-f8b9e33d3446f4aed9c9b9ff0a3ed476301f213bb86f66d74885d22b890331ecR84
I'm using github.com/99designs/gqlgen v0.17.76
Schema:
```graphql
type Mutation {
createBankToken(input: CreateBankTokenInput!): CreateBankTokenOutput! @authz(external: "write:*") @deprecated(reason: "Use createBankTokenV2 instead")
}
input CreateBankTokenInput {
verificationToken: String!
verificationCode: String!
}
type CreateBankTokenOutput {
token: BankToken
}
type BankToken {
token: String!
expiresIn: Int!
}
````
Introspection Result:
```json
{
"name": "createBankToken",
"description": null,
"isDeprecated": true,
"deprecationReason": "Use createBankTokenV2 instead",
"args": [
{
"name": "input",
"description": null,
"defaultValue": null,
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "INPUT_OBJECT",
"name": "CreateBankTokenInput",
"ofType": null
}
},
"isDeprecated": true,
"deprecationReason": "Use createBankTokenV2 instead"
}
],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "CreateBankTokenOutput",
"ofType": null
}
}
},
```
Guia de contribuição
Direção de pesquisa
A issue aponta para um commit e uma linha específicos na codebase onde a lógica de deprecation provavelmente está sendo tratada de forma incorreta. Comece examinando a lógica de introspection em torno da deprecation de fields e arguments no source do gqlgen, especialmente o arquivo referenciado. Escreva um test que reproduza a saída de introspection descrita para confirmar o bug, depois ajuste a lógica para marcar arguments como deprecated apenas quando eles tiverem sua própria @deprecated directive. Verifique executando os tests existentes relacionados a schema introspection e deprecation.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- go, graphql
- Domínio
- api, backend
- Tipo de issue
- Bug
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 65/100