{"action":"created","issue":{"url":"https://api.github.com/repos/graphql-java/graphql-java/issues/1293","repository_url":"https://api.github.com/repos/graphql-java/graphql-java","labels_url":"https://api.github.com/repos/graphql-java/graphql-java/issues/1293/labels{/name}","comments_url":"https://api.github.com/repos/graphql-java/graphql-java/issues/1293/comments","events_url":"https://api.github.com/repos/graphql-java/graphql-java/issues/1293/events","html_url":"https://github.com/graphql-java/graphql-java/issues/1293","id":376138132,"node_id":"MDU6SXNzdWUzNzYxMzgxMzI=","number":1293,"title":"Interests in a BinaryTreeTypeRegistry in upstream lib","user":{"login":"zcourts","id":692396,"node_id":"MDQ6VXNlcjY5MjM5Ng==","avatar_url":"https://avatars3.githubusercontent.com/u/692396?v=4","gravatar_id":"","url":"https://api.github.com/users/zcourts","html_url":"https://github.com/zcourts","followers_url":"https://api.github.com/users/zcourts/followers","following_url":"https://api.github.com/users/zcourts/following{/other_user}","gists_url":"https://api.github.com/users/zcourts/gists{/gist_id}","starred_url":"https://api.github.com/users/zcourts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zcourts/subscriptions","organizations_url":"https://api.github.com/users/zcourts/orgs","repos_url":"https://api.github.com/users/zcourts/repos","events_url":"https://api.github.com/users/zcourts/events{/privacy}","received_events_url":"https://api.github.com/users/zcourts/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-10-31T20:02:57Z","updated_at":"2018-11-05T01:44:05Z","closed_at":null,"author_association":"NONE","body":"Hello all,\r\nThis issue is to get an idea of whether there's any interest in a binary tree style type registry in the upstream graphql-java.\r\nWe've created this as a result of how we do what others commonly call \"schema stitching\". \r\n\r\n**Some background**\r\nWe allow third party developers to define schemas for the apps they submit to our platform. We also allow a developer to `depend` on existing app's schemas. Dev 1 published Schema1 and Dev 2 can depend on Schema1 in their new Schema2 inheriting all the types and functions in it.\r\n\r\nUntil now we've been taking the two independent type registries and copying everything from both and merging into a new schema. This has proven to be a bit fragile and as graphql-java is tending towards immutable definitions everywhere it's becoming tricky to do everything we were doing before.\r\n\r\n**The proposal**\r\nAs a result we're currently working on what amounts to a binary tree (sort of) type registry.\r\nThe registry itself stores all the SDL types the current graphql-java `TypeDefinitionRegistry` stores and in addition also stores two references to other `TypeDefintionRegistry` objects (optionally).\r\n\r\nThis is a left-biased binary tree hierarchical type registry i.e.\r\nWhen an operation is performed, it first operates on the current instance (hence why I said sort of a binary tree because if first checks current instance followed by LHS then RHS), if the current instance cannot fulfil the operation\r\n\r\n1. The left-hand side parent registry has the same operation attempted. If the the direct parent is also a\r\n{@link BinaryTreeTypeRegistry} then it will attempt the operation and then on its parents (both left and right parents if any), this will repeat until no parents are found.\r\n2. If the left hand side fails, the right-hand side is attempted and it in turn attempts to use all its parents until none are found\r\n3. Finally, if neither this node in the tree or any of its parents can fulfil the operation, it will fail.\r\nThe method of failure depends on the operation but is generally an exception or an empty {@link Optional}.\r\n\r\nAs I was doing the initial work on this it occurred to me that it may generally be useful outside of our use case so I'm creating this issue to see if there's any interest in having a PR for it to be merged in upstream.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/graphql-java/graphql-java/issues/comments/435731083","html_url":"https://github.com/graphql-java/graphql-java/issues/1293#issuecomment-435731083","issue_url":"https://api.github.com/repos/graphql-java/graphql-java/issues/1293","id":435731083,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTczMTA4Mw==","user":{"login":"zcourts","id":692396,"node_id":"MDQ6VXNlcjY5MjM5Ng==","avatar_url":"https://avatars3.githubusercontent.com/u/692396?v=4","gravatar_id":"","url":"https://api.github.com/users/zcourts","html_url":"https://github.com/zcourts","followers_url":"https://api.github.com/users/zcourts/followers","following_url":"https://api.github.com/users/zcourts/following{/other_user}","gists_url":"https://api.github.com/users/zcourts/gists{/gist_id}","starred_url":"https://api.github.com/users/zcourts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zcourts/subscriptions","organizations_url":"https://api.github.com/users/zcourts/orgs","repos_url":"https://api.github.com/users/zcourts/repos","events_url":"https://api.github.com/users/zcourts/events{/privacy}","received_events_url":"https://api.github.com/users/zcourts/received_events","type":"User","site_admin":false},"created_at":"2018-11-05T01:44:05Z","updated_at":"2018-11-05T01:44:05Z","author_association":"NONE","body":"That's good to hear! I actually did a quick prototype before I flew (conference for the week). The implementation is beyond rough, but is functional.\r\n\r\nCopy and pasted the impl here https://gist.github.com/zcourts/2a2dc316310b7344794ddef64c6ca690#file-binarytreetyperegistry-java-L226\r\n\r\nLine 226 linked is the biggest atrocity of the impl.\r\nIt demonstrates the point though and does work. "}}
{"actor":{"display_login":"zcourts"}}