Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

236
Visualizações
Is it possible to have schema directives for input parameters?

I have already created a hasRole directive. I only want to include certain input parameters if the user has the admin role:

const typeDefs = gql`

  type Article {
    id: ID!
    title: String!
    content: String!
    sponsor: String
  }

  input CreateArticleInput {
     title: String!
     content: String!
     sponsor: String // include if @hasRole(role: "admin")

  type Mutation {
    createArticle(input: CreateArticleInput!): Article!
    publishArticle(articleId: ID!): Boolean! @hasRole(role: "editor")

  }
`

The goal is to provide the sponsor input parameter optionally if the user has the role "admin", otherwise, do not let the user include a "sponsor". I wonder if the native @include or @skip directives can be used in tandem with my custom @hasRole directive to achieve this? ..just a thought.

Is something like this possible? I am not even sure if this is allowed in the input type.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda