Skip to content

DataFetchingFieldSelectionSetImpl getFields with child path #2505

@ejouvin

Description

@ejouvin

Describe the bug
Failed to retrieve children path when use on Windows.

To Reproduce
Please provide a code example or even better a test to reproduce the bug.
Only on windows.

In a schema with returns a connection and should have
edge {
node {
photo
}
}

For object
DataFetchingEnvironment env

List fields = toto.getFields("edges", "node/photo", "node\photo");
It does not return any fields

Problem comes from the resolve pattern

    @Override
    public List<SelectedField> getFields(String fieldGlobPattern, String... fieldGlobPatterns) {
        if (fieldGlobPattern == null || fieldGlobPattern.isEmpty()) {
            return emptyList();
        }
        computeValuesLazily();

        List<String> targetNames = new ArrayList<>();
        for (String flattenedField : flattenedFieldsForGlobSearching) {
            for (String globPattern : mkIterable(fieldGlobPattern, fieldGlobPatterns)) {
                PathMatcher globMatcher = globMatcher(globPattern);
                Path path = Paths.get(flattenedField);
                if (globMatcher.matches(path)) {
                    targetNames.add(flattenedField);
                }
            }
        }

        return toSetSemanticsList(targetNames.stream()
                .flatMap(name -> normalisedSelectionSetFields.getOrDefault(name, emptyList()).stream()));
    }

Because this is on windows, the value for Path path = Paths.get(flattenedField);
will be edge\node\photo
But the mkIterable(fieldGlobPattern, fieldGlobPatterns) produce :

  • edge
  • edge\node\photo
  • edge\node\photo

So no matching.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions