@aws-amplify/graphql-model-transformer 0.8.0-beta.0 → 0.8.0-beta.1

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.
@@ -1,5 +1,5 @@
1
+ import { DirectiveWrapper } from '@aws-amplify/graphql-transformer-core';
1
2
  import {
2
- ArgumentNode,
3
3
  DirectiveNode,
4
4
  DocumentNode,
5
5
  EnumTypeDefinitionNode,
@@ -11,13 +11,10 @@ import {
11
11
  ListTypeNode,
12
12
  Location,
13
13
  NamedTypeNode,
14
- NameNode,
15
14
  NonNullTypeNode,
16
15
  ObjectTypeDefinitionNode,
17
16
  StringValueNode,
18
17
  TypeNode,
19
- valueFromASTUntyped,
20
- ValueNode,
21
18
  } from 'graphql';
22
19
  import {
23
20
  DEFAULT_SCALARS,
@@ -29,53 +26,6 @@ import {
29
26
  withNamedNodeNamed,
30
27
  } from 'graphql-transformer-common';
31
28
 
32
- // Todo: to be moved to core later. context.output.getObject would return wrapper type so its easier to manipulate
33
- // objects
34
-
35
- export class ArgumentWrapper {
36
- public readonly name: NameNode;
37
- public readonly value: ValueNode;
38
- constructor(argument: ArgumentNode) {
39
- this.name = argument.name;
40
- this.value = argument.value;
41
- }
42
- serialize = (): ArgumentNode => {
43
- return {
44
- kind: 'Argument',
45
- name: this.name,
46
- value: this.value,
47
- };
48
- };
49
- }
50
-
51
- export class DirectiveWrapper {
52
- private arguments: ArgumentWrapper[] = [];
53
- private name: NameNode;
54
- private location?: Location;
55
- constructor(node: DirectiveNode) {
56
- this.name = node.name;
57
- this.arguments = (node.arguments || []).map(arg => new ArgumentWrapper(arg));
58
- this.location = this.location;
59
- }
60
- public serialize = (): DirectiveNode => {
61
- return {
62
- kind: 'Directive',
63
- name: this.name,
64
- arguments: this.arguments.map(arg => arg.serialize()),
65
- };
66
- };
67
- public getArguments = <T>(defaultValue: Required<T>): Required<T> => {
68
- const argValues = this.arguments.reduce(
69
- (acc: Record<string, any>, arg: ArgumentWrapper) => ({
70
- ...acc,
71
- [arg.name.value]: valueFromASTUntyped(arg.value),
72
- }),
73
- {},
74
- );
75
- return Object.assign(defaultValue, argValues);
76
- };
77
- }
78
-
79
29
  export class GenericFieldWrapper {
80
30
  protected type: TypeNode;
81
31
  public readonly directives: DirectiveWrapper[];