@eddeee888/gcg-typescript-resolver-files
Version:
This [GraphQL Code Generator](https://www.the-guild.dev/graphql/codegen) plugin creates resolvers given GraphQL schema.
24 lines • 1.16 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.isMatchResolverNamePattern = void 0;
const tslib_1 = require("tslib");
const micromatch_1 = tslib_1.__importDefault(require("micromatch"));
/**
* @description Wrapper function to return true if `value` matches on of the `pattern`s
*/
const isMatchResolverNamePattern = ({ pattern, value, }) => {
const normalizedPatterns = typeof pattern === 'string' ? [pattern] : pattern;
const nonEmptyNormalizedPatterns = normalizedPatterns.filter(Boolean);
const matchedValues = (0, micromatch_1.default)([value], nonEmptyNormalizedPatterns, {
// `micromatch` mainly matches filesystems whilst we want this function
// to match object-like path pattern e.g.
// - `book.Query.books`
// - `book.Book`
// - `.BookResult` (in the case where module mode are merged i.e. `mode=merged`)
// so set `dot=true` to treat `.` the same as other characters
dot: true,
});
return matchedValues.length > 0;
};
exports.isMatchResolverNamePattern = isMatchResolverNamePattern;
//# sourceMappingURL=isMatchResolverNamePattern.js.map
;