graphql / graphql/graphql-js

Proposal: Faster Algorithm For OverlappingFieldsCanBeMerged

Open
#2,185 3 comments 8 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
20.3k
Forks
2.1k
Avg merge
44m
Merged PRs (30d)
6

Description

At [XING](https://www.xing.com) we are using the [Sangria](https://sangria-graphql.org) implementation of GraphQL. The implementation of the OverlappingFieldsCanBeMerged validation in Sangria follows the one in this reference implementation. We experienced performance problems with it related to the number of fragments. After we invested some time to solve it, I came up with a better algorithm, that we are using now.

- [Here](https://tech.new-work.se/graphql-overlapping-fields-can-be-merged-fast-ea6e92e0a01) is the description of the algorithm.
- And [here](https://github.com/sangria-graphql/sangria/pull/458) is our PR for Sangria.

The proposal would be to use this algorithm in the reference implementation. Below is an example benchmark graph showing the performance improvement for multiple fragments in the same selection set.

![2019-09-16 NoOverlapFrag](https://user-images.githubusercontent.com/93972/65224756-19095d00-dac4-11e9-99ad-03f64c6d4459.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.