@graphql-tools/stitching-directives 3.0.0-alpha-be1b2ebd.0 → 3.0.0-alpha-20230517123108-df347e95

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. package/README.md +0 -2
  2. package/cjs/defaultStitchingDirectiveOptions.js +10 -0
  3. package/cjs/extractVariables.js +52 -0
  4. package/cjs/federationToStitchingSDL.js +114 -0
  5. package/cjs/getSourcePaths.js +25 -0
  6. package/cjs/index.js +6 -0
  7. package/cjs/package.json +1 -0
  8. package/cjs/parseMergeArgsExpr.js +69 -0
  9. package/cjs/pathsFromSelectionSet.js +31 -0
  10. package/cjs/preparseMergeArgsExpr.js +31 -0
  11. package/cjs/properties.js +70 -0
  12. package/cjs/stitchingDirectives.js +78 -0
  13. package/cjs/stitchingDirectivesTransformer.js +423 -0
  14. package/cjs/stitchingDirectivesValidator.js +120 -0
  15. package/cjs/types.js +0 -0
  16. package/esm/defaultStitchingDirectiveOptions.js +7 -0
  17. package/esm/extractVariables.js +48 -0
  18. package/esm/federationToStitchingSDL.js +110 -0
  19. package/esm/getSourcePaths.js +21 -0
  20. package/esm/index.js +3 -0
  21. package/esm/parseMergeArgsExpr.js +65 -0
  22. package/esm/pathsFromSelectionSet.js +27 -0
  23. package/esm/preparseMergeArgsExpr.js +27 -0
  24. package/esm/properties.js +63 -0
  25. package/esm/stitchingDirectives.js +74 -0
  26. package/esm/stitchingDirectivesTransformer.js +419 -0
  27. package/esm/stitchingDirectivesValidator.js +116 -0
  28. package/esm/types.js +0 -0
  29. package/package.json +40 -15
  30. package/typings/defaultStitchingDirectiveOptions.d.cts +2 -0
  31. package/{defaultStitchingDirectiveOptions.d.ts → typings/defaultStitchingDirectiveOptions.d.ts} +1 -1
  32. package/typings/extractVariables.d.cts +7 -0
  33. package/{extractVariables.d.ts → typings/extractVariables.d.ts} +1 -1
  34. package/typings/federationToStitchingSDL.d.cts +2 -0
  35. package/{federationToStitchingSDL.d.ts → typings/federationToStitchingSDL.d.ts} +1 -1
  36. package/typings/getSourcePaths.d.cts +3 -0
  37. package/{getSourcePaths.d.ts → typings/getSourcePaths.d.ts} +1 -1
  38. package/typings/index.d.cts +3 -0
  39. package/typings/index.d.ts +3 -0
  40. package/typings/parseMergeArgsExpr.d.cts +3 -0
  41. package/{parseMergeArgsExpr.d.ts → typings/parseMergeArgsExpr.d.ts} +1 -1
  42. package/typings/pathsFromSelectionSet.d.ts +2 -0
  43. package/typings/preparseMergeArgsExpr.d.ts +6 -0
  44. package/typings/properties.d.cts +5 -0
  45. package/{properties.d.ts → typings/properties.d.ts} +1 -1
  46. package/typings/stitchingDirectives.d.cts +19 -0
  47. package/{stitchingDirectives.d.ts → typings/stitchingDirectives.d.ts} +1 -1
  48. package/typings/stitchingDirectivesTransformer.d.cts +3 -0
  49. package/{stitchingDirectivesTransformer.d.ts → typings/stitchingDirectivesTransformer.d.ts} +1 -1
  50. package/typings/stitchingDirectivesValidator.d.cts +3 -0
  51. package/{stitchingDirectivesValidator.d.ts → typings/stitchingDirectivesValidator.d.ts} +1 -1
  52. package/typings/types.d.cts +35 -0
  53. package/{types.d.ts → typings/types.d.ts} +3 -3
  54. package/index.d.ts +0 -3
  55. package/index.js +0 -972
  56. package/index.mjs +0 -967
  57. /package/{pathsFromSelectionSet.d.ts → typings/pathsFromSelectionSet.d.cts} +0 -0
  58. /package/{preparseMergeArgsExpr.d.ts → typings/preparseMergeArgsExpr.d.cts} +0 -0
@@ -0,0 +1,3 @@
1
+ export * from './stitchingDirectives.cjs';
2
+ export * from './types.cjs';
3
+ export * from './federationToStitchingSDL.cjs';
@@ -0,0 +1,3 @@
1
+ export * from './stitchingDirectives.js';
2
+ export * from './types.js';
3
+ export * from './federationToStitchingSDL.js';
@@ -0,0 +1,3 @@
1
+ import { SelectionSetNode } from 'graphql';
2
+ import { ParsedMergeArgsExpr } from './types.cjs';
3
+ export declare function parseMergeArgsExpr(mergeArgsExpr: string, selectionSet?: SelectionSetNode): ParsedMergeArgsExpr;
@@ -1,3 +1,3 @@
1
1
  import { SelectionSetNode } from 'graphql';
2
- import { ParsedMergeArgsExpr } from './types';
2
+ import { ParsedMergeArgsExpr } from './types.js';
3
3
  export declare function parseMergeArgsExpr(mergeArgsExpr: string, selectionSet?: SelectionSetNode): ParsedMergeArgsExpr;
@@ -0,0 +1,2 @@
1
+ import { SelectionSetNode } from 'graphql';
2
+ export declare function pathsFromSelectionSet(selectionSet: SelectionSetNode, path?: Array<string>): Array<Array<string>>;
@@ -0,0 +1,6 @@
1
+ export declare const KEY_DELIMITER = "__dot__";
2
+ export declare const EXPANSION_PREFIX = "__exp";
3
+ export declare function preparseMergeArgsExpr(mergeArgsExpr: string): {
4
+ mergeArgsExpr: string;
5
+ expansionExpressions: Record<string, string>;
6
+ };
@@ -0,0 +1,5 @@
1
+ import { PropertyTree } from './types.cjs';
2
+ export declare function addProperty(object: Record<string, any>, path: Array<string | number>, value: any): void;
3
+ export declare function getProperty(object: Record<string, any>, path: Array<string>): any;
4
+ export declare function getProperties(object: Record<string, any>, propertyTree: PropertyTree): any;
5
+ export declare function propertyTreeFromPaths(paths: Array<Array<string>>): PropertyTree;
@@ -1,4 +1,4 @@
1
- import { PropertyTree } from './types';
1
+ import { PropertyTree } from './types.js';
2
2
  export declare function addProperty(object: Record<string, any>, path: Array<string | number>, value: any): void;
3
3
  export declare function getProperty(object: Record<string, any>, path: Array<string>): any;
4
4
  export declare function getProperties(object: Record<string, any>, propertyTree: PropertyTree): any;
@@ -0,0 +1,19 @@
1
+ import { GraphQLDirective, GraphQLSchema } from 'graphql';
2
+ import { SubschemaConfig } from '@graphql-tools/delegate';
3
+ import { StitchingDirectivesOptions } from './types.cjs';
4
+ export interface StitchingDirectivesResult {
5
+ keyDirectiveTypeDefs: string;
6
+ computedDirectiveTypeDefs: string;
7
+ mergeDirectiveTypeDefs: string;
8
+ canonicalDirectiveTypeDefs: string;
9
+ stitchingDirectivesTypeDefs: string;
10
+ allStitchingDirectivesTypeDefs: string;
11
+ stitchingDirectivesValidator: (schema: GraphQLSchema) => GraphQLSchema;
12
+ stitchingDirectivesTransformer: (subschemaConfig: SubschemaConfig) => SubschemaConfig;
13
+ keyDirective: GraphQLDirective;
14
+ computedDirective: GraphQLDirective;
15
+ mergeDirective: GraphQLDirective;
16
+ canonicalDirective: GraphQLDirective;
17
+ allStitchingDirectives: Array<GraphQLDirective>;
18
+ }
19
+ export declare function stitchingDirectives(options?: StitchingDirectivesOptions): StitchingDirectivesResult;
@@ -1,6 +1,6 @@
1
1
  import { GraphQLDirective, GraphQLSchema } from 'graphql';
2
2
  import { SubschemaConfig } from '@graphql-tools/delegate';
3
- import { StitchingDirectivesOptions } from './types';
3
+ import { StitchingDirectivesOptions } from './types.js';
4
4
  export interface StitchingDirectivesResult {
5
5
  keyDirectiveTypeDefs: string;
6
6
  computedDirectiveTypeDefs: string;
@@ -0,0 +1,3 @@
1
+ import { SubschemaConfig } from '@graphql-tools/delegate';
2
+ import { StitchingDirectivesOptions } from './types.cjs';
3
+ export declare function stitchingDirectivesTransformer(options?: StitchingDirectivesOptions): (subschemaConfig: SubschemaConfig) => SubschemaConfig;
@@ -1,3 +1,3 @@
1
1
  import { SubschemaConfig } from '@graphql-tools/delegate';
2
- import { StitchingDirectivesOptions } from './types';
2
+ import { StitchingDirectivesOptions } from './types.js';
3
3
  export declare function stitchingDirectivesTransformer(options?: StitchingDirectivesOptions): (subschemaConfig: SubschemaConfig) => SubschemaConfig;
@@ -0,0 +1,3 @@
1
+ import { GraphQLSchema } from 'graphql';
2
+ import { StitchingDirectivesOptions } from './types.cjs';
3
+ export declare function stitchingDirectivesValidator(options?: StitchingDirectivesOptions): (schema: GraphQLSchema) => GraphQLSchema;
@@ -1,3 +1,3 @@
1
1
  import { GraphQLSchema } from 'graphql';
2
- import { StitchingDirectivesOptions } from './types';
2
+ import { StitchingDirectivesOptions } from './types.js';
3
3
  export declare function stitchingDirectivesValidator(options?: StitchingDirectivesOptions): (schema: GraphQLSchema) => GraphQLSchema;
@@ -0,0 +1,35 @@
1
+ export interface PropertyTree {
2
+ [property: string]: null | PropertyTree;
3
+ }
4
+ export interface ParsedMergeArgsExpr {
5
+ args: Record<string, any>;
6
+ usedProperties: PropertyTree;
7
+ mappingInstructions?: Array<MappingInstruction>;
8
+ expansions?: Array<Expansion>;
9
+ }
10
+ export interface MappingInstruction {
11
+ destinationPath: Array<string>;
12
+ sourcePath: Array<string>;
13
+ }
14
+ export interface Expansion {
15
+ valuePath: Array<string>;
16
+ value: any;
17
+ mappingInstructions: Array<MappingInstruction>;
18
+ }
19
+ export type VariablePaths = Record<string, Array<string | number>>;
20
+ export interface StitchingDirectivesOptions {
21
+ keyDirectiveName?: string;
22
+ computedDirectiveName?: string;
23
+ mergeDirectiveName?: string;
24
+ canonicalDirectiveName?: string;
25
+ pathToDirectivesInExtensions?: Array<string>;
26
+ }
27
+ type Complete<T> = {
28
+ [P in keyof Required<T>]: Exclude<Pick<T, P> extends Required<Pick<T, P>> ? T[P] : T[P] | undefined, undefined>;
29
+ };
30
+ export type StitchingDirectivesFinalOptions = Complete<StitchingDirectivesOptions>;
31
+ export interface MergedTypeResolverInfo extends ParsedMergeArgsExpr {
32
+ fieldName: string;
33
+ returnsList: boolean;
34
+ }
35
+ export {};
@@ -16,7 +16,7 @@ export interface Expansion {
16
16
  value: any;
17
17
  mappingInstructions: Array<MappingInstruction>;
18
18
  }
19
- export declare type VariablePaths = Record<string, Array<string | number>>;
19
+ export type VariablePaths = Record<string, Array<string | number>>;
20
20
  export interface StitchingDirectivesOptions {
21
21
  keyDirectiveName?: string;
22
22
  computedDirectiveName?: string;
@@ -24,10 +24,10 @@ export interface StitchingDirectivesOptions {
24
24
  canonicalDirectiveName?: string;
25
25
  pathToDirectivesInExtensions?: Array<string>;
26
26
  }
27
- declare type Complete<T> = {
27
+ type Complete<T> = {
28
28
  [P in keyof Required<T>]: Exclude<Pick<T, P> extends Required<Pick<T, P>> ? T[P] : T[P] | undefined, undefined>;
29
29
  };
30
- export declare type StitchingDirectivesFinalOptions = Complete<StitchingDirectivesOptions>;
30
+ export type StitchingDirectivesFinalOptions = Complete<StitchingDirectivesOptions>;
31
31
  export interface MergedTypeResolverInfo extends ParsedMergeArgsExpr {
32
32
  fieldName: string;
33
33
  returnsList: boolean;
package/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './stitchingDirectives';
2
- export * from './types';
3
- export * from './federationToStitchingSDL';