@graphql-mesh/transform-filter-schema 1.0.0-alpha-20230424113259-560b18922 → 1.0.0-alpha-20230522110904-130abe0f9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/bareFilter.js CHANGED
@@ -40,7 +40,7 @@ class BareFilter {
40
40
  return undefined;
41
41
  }
42
42
  transformSchema(schema) {
43
- const transformedSchema = (0, utils_1.mapSchema)(schema, {
43
+ let transformedSchema = (0, utils_1.mapSchema)(schema, {
44
44
  ...(this.typeGlobs.length && {
45
45
  [utils_1.MapperKind.TYPE]: type => this.matchInArray(this.typeGlobs, type.toString()),
46
46
  }),
@@ -72,6 +72,12 @@ class BareFilter {
72
72
  },
73
73
  }),
74
74
  });
75
+ transformedSchema = (0, utils_1.mapSchema)(transformedSchema, {
76
+ [utils_1.MapperKind.ROOT_OBJECT]: type => {
77
+ if (Object.keys(type.getFields()).length === 0)
78
+ return null;
79
+ },
80
+ });
75
81
  return transformedSchema;
76
82
  }
77
83
  }
package/cjs/wrapFilter.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const minimatch_1 = tslib_1.__importDefault(require("minimatch"));
5
5
  const utils_1 = require("@graphql-mesh/utils");
6
+ const utils_2 = require("@graphql-tools/utils");
6
7
  const wrap_1 = require("@graphql-tools/wrap");
7
8
  class WrapFilter {
8
9
  constructor({ config: { filters } }) {
@@ -68,7 +69,14 @@ class WrapFilter {
68
69
  }
69
70
  }
70
71
  transformSchema(originalWrappingSchema, subschemaConfig, transformedSchema) {
71
- return (0, utils_1.applySchemaTransforms)(originalWrappingSchema, subschemaConfig, transformedSchema, this.transforms);
72
+ let finalSchema = (0, utils_1.applySchemaTransforms)(originalWrappingSchema, subschemaConfig, transformedSchema, this.transforms);
73
+ finalSchema = (0, utils_2.mapSchema)(finalSchema, {
74
+ [utils_2.MapperKind.ROOT_OBJECT]: type => {
75
+ if (Object.keys(type.getFields()).length === 0)
76
+ return null;
77
+ },
78
+ });
79
+ return finalSchema;
72
80
  }
73
81
  transformRequest(originalRequest, delegationContext, transformationContext) {
74
82
  return (0, utils_1.applyRequestTransforms)(originalRequest, delegationContext, transformationContext, this.transforms);
package/esm/bareFilter.js CHANGED
@@ -37,7 +37,7 @@ export default class BareFilter {
37
37
  return undefined;
38
38
  }
39
39
  transformSchema(schema) {
40
- const transformedSchema = mapSchema(schema, {
40
+ let transformedSchema = mapSchema(schema, {
41
41
  ...(this.typeGlobs.length && {
42
42
  [MapperKind.TYPE]: type => this.matchInArray(this.typeGlobs, type.toString()),
43
43
  }),
@@ -69,6 +69,12 @@ export default class BareFilter {
69
69
  },
70
70
  }),
71
71
  });
72
+ transformedSchema = mapSchema(transformedSchema, {
73
+ [MapperKind.ROOT_OBJECT]: type => {
74
+ if (Object.keys(type.getFields()).length === 0)
75
+ return null;
76
+ },
77
+ });
72
78
  return transformedSchema;
73
79
  }
74
80
  }
package/esm/wrapFilter.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import minimatch from 'minimatch';
2
2
  import { applyRequestTransforms, applyResultTransforms, applySchemaTransforms, } from '@graphql-mesh/utils';
3
+ import { MapperKind, mapSchema } from '@graphql-tools/utils';
3
4
  import { FilterInputObjectFields, FilterInterfaceFields, FilterObjectFields, FilterRootFields, FilterTypes, TransformCompositeFields, } from '@graphql-tools/wrap';
4
5
  export default class WrapFilter {
5
6
  constructor({ config: { filters } }) {
@@ -65,7 +66,14 @@ export default class WrapFilter {
65
66
  }
66
67
  }
67
68
  transformSchema(originalWrappingSchema, subschemaConfig, transformedSchema) {
68
- return applySchemaTransforms(originalWrappingSchema, subschemaConfig, transformedSchema, this.transforms);
69
+ let finalSchema = applySchemaTransforms(originalWrappingSchema, subschemaConfig, transformedSchema, this.transforms);
70
+ finalSchema = mapSchema(finalSchema, {
71
+ [MapperKind.ROOT_OBJECT]: type => {
72
+ if (Object.keys(type.getFields()).length === 0)
73
+ return null;
74
+ },
75
+ });
76
+ return finalSchema;
69
77
  }
70
78
  transformRequest(originalRequest, delegationContext, transformationContext) {
71
79
  return applyRequestTransforms(originalRequest, delegationContext, transformationContext, this.transforms);
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@graphql-mesh/transform-filter-schema",
3
- "version": "1.0.0-alpha-20230424113259-560b18922",
3
+ "version": "1.0.0-alpha-20230522110904-130abe0f9",
4
4
  "sideEffects": false,
5
5
  "peerDependencies": {
6
- "@graphql-mesh/types": "1.0.0-alpha-20230424113259-560b18922",
7
- "@graphql-mesh/utils": "1.0.0-alpha-20230424113259-560b18922",
6
+ "@graphql-mesh/types": "1.0.0-alpha-20230522110904-130abe0f9",
7
+ "@graphql-mesh/utils": "1.0.0-alpha-20230522110904-130abe0f9",
8
8
  "@graphql-tools/utils": "^9.2.1",
9
9
  "graphql": "*",
10
10
  "tslib": "^2.4.0"