public void aggregate()

in src/main/java/org/apache/sling/graphql/schema/aggregator/impl/DefaultSchemaAggregator.java [98:129]


    public void aggregate(Writer target, String ...providerNamesOrRegexp) throws IOException {
        final String info = String.format("Schema aggregated by %s%n", getClass().getSimpleName());
        target.write(String.format("# %s", info));

        // build list of selected providers
        final Map<PartialInfo, Partial> providers = tracker.getSchemaProviders();
        if(log.isDebugEnabled()) {
            log.debug("Aggregating schemas, request={}, providers={}", Arrays.asList(providerNamesOrRegexp), providers.keySet());
        }
        final Set<String> missing = new HashSet<>();
        final Set<Partial> selected = selectProviders(providers, missing, providerNamesOrRegexp);

        if(!missing.isEmpty()) {
            log.debug("Requested providers {} not found in {}", missing, providers.keySet());
            throw new IOException(String.format("Missing providers: %s", missing));
        }

        // copy sections that belong in the output SDL
        copySection(selected, Partial.SectionName.PROLOGUE, OutputMode.NO_BLOCK, target);
        copySection(selected, Partial.SectionName.QUERY, OutputMode.WITH_BLOCK, target);
        copySection(selected, Partial.SectionName.MUTATION, OutputMode.WITH_BLOCK_IF_NOT_EMPTY, target);
        copySection(selected, Partial.SectionName.TYPES, OutputMode.NO_BLOCK, target);

        final StringBuilder partialNames = new StringBuilder();
        selected.forEach(p -> {
            if(partialNames.length() > 0) {
                partialNames.append(",");
            }
            partialNames.append(p.getPartialInfo());
        });
        target.write(String.format("%n# End of Schema aggregated from {%s} by %s", partialNames, getClass().getSimpleName()));
    }