Skip to content

add dependency graph - #1594

Closed
andimarek wants to merge 15 commits into
masterfrom
dep-graph
Closed

andimarek wants to merge 15 commits into
masterfrom
dep-graph

Conversation

@andimarek

Copy link
Copy Markdown
Member

@gkesler @exbe here is my early PR for adding the dependency graph. Not really ready yet.

Inside createDependencyGraph it creates dot file representation of the graph which you can try out for example here: https://dreampuf.github.io/GraphvizOnline/

Set<FieldVertex> curSourceSet = new LinkedHashSet<>();
curSourceSet.add(rootVertex);

while (!curSourceSet.isEmpty()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andimarek
This is a topological sorting algorithm.
Currently it is used to perform static analysis only, but it actually needs to be used to do the field resolution.
The main difference between these 2 cases is that during query execution the actual runtime data should be used to evaluate vertex predicate and if that fails, that vertex and all its dependents should be excluded from the topological sequence so they won't make their entries in the resulting object.

traverser.rootVar(FieldVertex.class, rootVertex);
allVertices.add(rootVertex);
List<MergedFieldWithType> roots = fieldCollector.collectFromOperation(parameters, operationDefinition, graphQLSchema.getQueryType());
traverser.traverse(roots, new TraverserVisitorStub<MergedFieldWithType>() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think recursive collecting fields (graph traversal!) and then traversing collected fields again to build a graph is quite redundant. I would suggest to build the graph in 1 traverse cycle, incrementally with field collection.

@andimarek andimarek added the Not to be merged spikes or other stuff that should never or not yet to be merged label Jan 12, 2020
@andimarek

Copy link
Copy Markdown
Member Author

outdated. We have now a ExecutableNormalizedOperation structure which can serve as basis for an execution plan

@andimarek andimarek closed this Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Not to be merged spikes or other stuff that should never or not yet to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants