Can directives like `include` and `skip` be used t...
# prisma-whats-new
f
Can directives like
include
and
skip
be used to conditionally execute mutations?
a
Yes
f
Brillo, thanks
😎 1
a
Copy code
mutation($skip: Boolean = true) {
  createPost(description: "test") @skip(if: $skip) 
  { 
    id 
  }
}
👍 1
f
can you have two directives?
Copy code
mutation($bar: Boolean = true $foo: Boolean = true) {
  createPost(description: "test") @skip(if: $foo) @skip(if: $bar) 
  { 
    id 
  }
}
a
Just open the Playground and have a go at it 🙂
Spoiler alert: no, you can't...
However, you can use @skip and @include together, so you have to flip one of your booleans...
f
haha, thanks for the spoilers
Ahh, right, I'll do that then, thank you 🙂
a
They are evaluated using 'AND', so @include(if: true) @skip(if: true) will still skip it
n
can you have two directives?
@freddie-codogo I would expose one boolean $fooOrBar and handle that logic in your client instead of the query
👍 1
👍🏻 1
@skip(if: $fooOrBar)
f
Nice idea Nilan, I'll see if that makes the code cleaner