Title: QueryTraverser only descends into FragmentSpreads once · Issue #1695 · graphql-java/graphql-java · GitHub
Open Graph Title: QueryTraverser only descends into FragmentSpreads once · Issue #1695 · graphql-java/graphql-java
X Title: QueryTraverser only descends into FragmentSpreads once · Issue #1695 · graphql-java/graphql-java
Description: When the same fragment is used multiple times, QueryTraverser descends into its field only once. A simple example: { users { ...userInfo friends { ...userInfo } } fragment userInfo on User { name } } On a query such as this, QueryTravers...
Open Graph Description: When the same fragment is used multiple times, QueryTraverser descends into its field only once. A simple example: { users { ...userInfo friends { ...userInfo } } fragment userInfo on User { name }...
X Description: When the same fragment is used multiple times, QueryTraverser descends into its field only once. A simple example: { users { ...userInfo friends { ...userInfo } } fragment userInfo on User { name }...
Opengraph URL: https://github.com/graphql-java/graphql-java/issues/1695
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"QueryTraverser only descends into FragmentSpreads once","articleBody":"When the same fragment is used multiple times, `QueryTraverser` descends into its field only once.\r\n\r\nA simple example:\r\n\r\n```graphql\r\n{\r\n users {\r\n ...userInfo\r\n friends {\r\n ...userInfo\r\n }\r\n }\r\n\r\n fragment userInfo on User {\r\n name\r\n }\r\n}\r\n```\r\n\r\nOn a query such as this, `QueryTraverser` will visit the `name` field only once (and will visit the `...userInfo` spread twice, as expected). This is distinctly different from the behavior one would get for a semantically equivalent query with no fragments:\r\n\r\n```graphql\r\n{\r\n users {\r\n name\r\n friends {\r\n name\r\n }\r\n }\r\n}\r\n```\r\nOne immediate implication is on query complexity analysis. A (malicious?) query with recursive fragment spreads will get a score underestimated by orders of magnitude.\r\n\r\nAs an example, `MaxQueryComplexityInstrumentation` will calculate the complexity of the full introspection query to be 45, while in reality over a 100 fields are requested. And that query isn't intentionally crafted to trick the calculation with large, recursive, fragment spreads.\r\n\r\n### Investigation\r\n\r\nThe reason why this happens is that `QueryTraverser` [in this line](https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/analysis/QueryTraverser.java#L158) considers `FragmentDefinition` the only child of each `FragmentSpread`. Since both spreads have the same definitions, when the traverser encounters the 2nd spread, it will falsely believe ([in this line](https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/util/DefaultTraverserContext.java#L149)) its children (the definition) have already been visited and will not descend.\r\n\r\nHappy to help fixing this, but I'd need guidance on the approach...","author":{"url":"https://github.com/kaqqao","@type":"Person","name":"kaqqao"},"datePublished":"2019-11-11T00:54:57Z","url":"https://github.com/graphql-java/graphql-java/issues/1695"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cd6b4639-6a36-716a-ef6b-2308402687ba |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C3C6:184D0E:34553:45A6E:6B017C53 |
| html-safe-nonce | db7a83669cdc81616075ac2ba045ce8d12e09c650f18beec34f8644a12641a05 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDM0M2OjE4NEQwRTozNDU1Mzo0NUE2RTo2QjAxN0M1MyIsInZpc2l0b3JfaWQiOiIyOTc1ODY2MjU4NjAxMzc2ODUxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5f7f1413a99ab5503fed97629c9dea0e241364bb03a2525b20c3fc53e0743eeb |
| hovercard-subject-tag | issue:520687334 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/graphql-java/graphql-java/1695/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9012084c3d9f7a573e983408db227ce539a5d517d0d6557994370d9151c62121/graphql-java/graphql-java/issues/1695 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9012084c3d9f7a573e983408db227ce539a5d517d0d6557994370d9151c62121/graphql-java/graphql-java/issues/1695 |
| og:image:alt | When the same fragment is used multiple times, QueryTraverser descends into its field only once. A simple example: { users { ...userInfo friends { ...userInfo } } fragment userInfo on User { name }... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kaqqao |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/graphql-java/graphql-java git https://github.com/graphql-java/graphql-java.git |
| octolytics-dimension-user_id | 14289921 |
| octolytics-dimension-user_login | graphql-java |
| octolytics-dimension-repository_id | 38602457 |
| octolytics-dimension-repository_nwo | graphql-java/graphql-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 38602457 |
| octolytics-dimension-repository_network_root_nwo | graphql-java/graphql-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width