DEV Community

Shruti Pahuja
Shruti Pahuja

Posted on

Default value for field with @include directive

I have a requirement of adding a @include directive for querying a field in a particular fragment.

This fragment is being used across different queries in multiple modules so I'm having to inject a value for this field from each of these queries. I

Is there any way to assign a default value to a directive at the site of the directive?

fragment sampleFragment on SampleFragment {
// want to assign a default value here
fragmentSample @include(if: $condition) {
// code here
}
}

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay