Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

235
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda