Add option to override "Cycle detected: Fragment"

Moved from GitHub dgraph/2510

Posted by mbudge:

Hi,

I’m wrote a query which legitimately reuses fragments, but we get the cycle detected error, which means we have to copy and rename the fragment.

Would it be possible to add an option to override the cycle detection?

{
     domain(func: has(domain)) @filter(eq(name, example.co.uk)) {
          ...UpdateFragment
     }
}

The query is quite large so I’m not going to copy the whole thing. But doing this to get round the cycle detection means we have more code to maintain, which could be buggy if we miss something.

fragment PortFrag {
     uid
     ...UpdateFragmentCopy
}
fragment AFragment {
	uid
	name
}
fragment AFragmentCopy {
	uid
	name
}```

manishrjain commented :

I think we can have a look at this and see if this ask is in line with how GraphQL does fragments. In general, seems like circular fragments are going to be an issue.

campoy commented :

Hi there,

Could you please give an example of a query that uses cyclic fragments and you would expect to work?
The fragments that you gave on the comment above are not cyclic.

Thanks

We are not planning to work on this anytime soon. If anyone has any examples or use cases that they have for this and then we can consider it again.