Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!