Skip to content

DataFetchingFieldSelectionSetImpl getFields with child path #2505

Closed

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.

Activity

  1. bbakerman commented on Aug 11, 2021

    @bbakerman
    Member

    Yikes - we want the glob support not for files but for logical names. Bugger

  2. bbakerman commented on Aug 15, 2021

    @bbakerman
    Member

    We have fixed this so that you still use a logical / (unix style) but if you are on windows it will flip under the covers for you so that the glob code we use will match.

    So as a consumer is not OS specific - we will ask you to enter / - but it will be change in Windows at runtime so that FileSystems.getDefault().getPathMatcher("glob:" + fieldGlobPattern) works.

    We use the path matcher aboe in Java to get a free "glob" matching lib - not for files but for logical names.

    but the specifics here caught us out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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