Skip to content
This repository has been archived by the owner on Sep 2, 2020. It is now read-only.

Initial fragment caching does not work for some glob patterns #221

Closed
mgadda opened this issue Apr 10, 2018 · 0 comments
Closed

Initial fragment caching does not work for some glob patterns #221

mgadda opened this issue Apr 10, 2018 · 0 comments
Assignees
Labels

Comments

@mgadda
Copy link
Collaborator

mgadda commented Apr 10, 2018

If .graphqlconfig contains an includes key, with only a single glob such as below, the resulting set of matched files will always be empty.

{
  "includes": [ "{path/to}/**/*.{js, graphql}" ]
}

In the above example, glob would ultimately look for files ending in .js or .graphql which are literally in a directory called {path/to}.

This occurs because the underlying library performing the globbing (minimatch), does not expand glob braces when there's only a single value inside those braces. For instance, some implementations of glob (such as your shell) expand {foo} into foo. Minimatch does not perform an expansion in this case. It's unclear if this is by design or not.

When includes contains multiple glob paths, this behavior does not occur because, as one would expect, minimatch correctly expands {path/a,path/b}/**/*.{js, graphql} into ['path/a/**.{js, graphql}', 'path/a/**.{js, graphql}'].

The end result is that fragments are not cached when graphql-language-service first loads in the above case. Caching is thus delayed until each file has changed (a fact which is learned only after being notified by watchman or via language service protocol).

@mgadda mgadda added the bug label Apr 10, 2018
@mgadda mgadda self-assigned this Apr 10, 2018
@mgadda mgadda closed this as completed in dde95d9 Apr 12, 2018
mgadda added a commit that referenced this issue Apr 12, 2018
Fixes #221 and #222 - fixes GraphQLCache file globbing
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant