Skip to content

Schema Usage support - #2548

Merged
bbakerman merged 7 commits into
masterfrom
schema-usage
Feb 4, 2022
Merged

Schema Usage support#2548
bbakerman merged 7 commits into
masterfrom
schema-usage

Conversation

@bbakerman

@bbakerman bbakerman commented Sep 15, 2021

Copy link
Copy Markdown
Member

A PR on getting schema usage stats and "reference" ability

@bbakerman bbakerman changed the title WIP - Schema Usage support Schema Usage support Jan 12, 2022
Comment thread src/main/java/graphql/Directives.java Outdated
}


private final static Set<String> SPECIFIED_DIRECTIVES = ImmutableSet.of(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we have the same methods/logic already in DirectiveInfo I believe.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

nice

@Internal
static class Builder {
Map<String, Integer> fieldReferenceCounts = new HashMap<>();
Map<String, Integer> inputFieldReferenceCounts = new HashMap<>();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would recommend ImmutableMaps.Builder here, which preserve the order and are immutable OR our beloved LinkedHashMap or a comment why the order is never interesting.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ImmutableMap.Builder does not support compute like behavior. I want to accumulate values (counts) against type names.

            private BiFunction<String, Integer, Integer> incCount() {
                return (k, v) -> v == null ? 1 : v + 1;
            }

builder.fieldReferenceCounts.compute(fieldType.getName(), incCount());

With map builder it has only PUT and no read capability for past values

So I cant use it. I do use it on getters however. I will improve it to create these once and once only

@bbakerman bbakerman added this to the 18.0 milestone Feb 4, 2022
@bbakerman
bbakerman merged commit 35b8dcd into master Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants