DEV Community

Discussion on: GraphQL Fragments and the benefits of using them

Collapse
 
tuucan1 profile image
Tuğcan • Edited

What's the advantage of using fragments over plain template literal variables?

For exm;

const someFields = '
{
   someThing
   someOtherThing
}
'

and then

const someQuery = gql'
something {
   ${someFields}
}
'

(assume backticks are used instead of ')