@aws-amplify/graphql-model-transformer 1.1.1-alpha.5 → 1.1.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.
- package/CHANGELOG.md +6 -0
- package/lib/directive.d.ts +1 -1
- package/lib/directive.d.ts.map +1 -1
- package/lib/graphql-model-transformer.d.ts +2 -2
- package/lib/graphql-model-transformer.d.ts.map +1 -1
- package/lib/graphql-model-transformer.js +1 -1
- package/lib/graphql-model-transformer.js.map +1 -1
- package/package.json +7 -8
- package/src/__tests__/__snapshots__/model-transformer.test.ts.snap +393 -0
- package/src/__tests__/model-transformer.test.ts +45 -0
- package/src/graphql-model-transformer.ts +2 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3893,6 +3893,399 @@ $util.toJson($UpdateItem)
|
|
|
3893
3893
|
## [End] Mutation Update resolver. **"
|
|
3894
3894
|
`;
|
|
3895
3895
|
|
|
3896
|
+
exports[`ModelTransformer: should successfully transform simple Embeddable type (non-model) schema 1`] = `
|
|
3897
|
+
"
|
|
3898
|
+
type NonModelType {
|
|
3899
|
+
id: ID!
|
|
3900
|
+
title: String!
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
input ModelStringInput {
|
|
3904
|
+
ne: String
|
|
3905
|
+
eq: String
|
|
3906
|
+
le: String
|
|
3907
|
+
lt: String
|
|
3908
|
+
ge: String
|
|
3909
|
+
gt: String
|
|
3910
|
+
contains: String
|
|
3911
|
+
notContains: String
|
|
3912
|
+
between: [String]
|
|
3913
|
+
beginsWith: String
|
|
3914
|
+
attributeExists: Boolean
|
|
3915
|
+
attributeType: ModelAttributeTypes
|
|
3916
|
+
size: ModelSizeInput
|
|
3917
|
+
}
|
|
3918
|
+
|
|
3919
|
+
input ModelIntInput {
|
|
3920
|
+
ne: Int
|
|
3921
|
+
eq: Int
|
|
3922
|
+
le: Int
|
|
3923
|
+
lt: Int
|
|
3924
|
+
ge: Int
|
|
3925
|
+
gt: Int
|
|
3926
|
+
between: [Int]
|
|
3927
|
+
attributeExists: Boolean
|
|
3928
|
+
attributeType: ModelAttributeTypes
|
|
3929
|
+
}
|
|
3930
|
+
|
|
3931
|
+
input ModelFloatInput {
|
|
3932
|
+
ne: Float
|
|
3933
|
+
eq: Float
|
|
3934
|
+
le: Float
|
|
3935
|
+
lt: Float
|
|
3936
|
+
ge: Float
|
|
3937
|
+
gt: Float
|
|
3938
|
+
between: [Float]
|
|
3939
|
+
attributeExists: Boolean
|
|
3940
|
+
attributeType: ModelAttributeTypes
|
|
3941
|
+
}
|
|
3942
|
+
|
|
3943
|
+
input ModelBooleanInput {
|
|
3944
|
+
ne: Boolean
|
|
3945
|
+
eq: Boolean
|
|
3946
|
+
attributeExists: Boolean
|
|
3947
|
+
attributeType: ModelAttributeTypes
|
|
3948
|
+
}
|
|
3949
|
+
|
|
3950
|
+
input ModelIDInput {
|
|
3951
|
+
ne: ID
|
|
3952
|
+
eq: ID
|
|
3953
|
+
le: ID
|
|
3954
|
+
lt: ID
|
|
3955
|
+
ge: ID
|
|
3956
|
+
gt: ID
|
|
3957
|
+
contains: ID
|
|
3958
|
+
notContains: ID
|
|
3959
|
+
between: [ID]
|
|
3960
|
+
beginsWith: ID
|
|
3961
|
+
attributeExists: Boolean
|
|
3962
|
+
attributeType: ModelAttributeTypes
|
|
3963
|
+
size: ModelSizeInput
|
|
3964
|
+
}
|
|
3965
|
+
|
|
3966
|
+
input ModelSubscriptionStringInput {
|
|
3967
|
+
ne: String
|
|
3968
|
+
eq: String
|
|
3969
|
+
le: String
|
|
3970
|
+
lt: String
|
|
3971
|
+
ge: String
|
|
3972
|
+
gt: String
|
|
3973
|
+
contains: String
|
|
3974
|
+
notContains: String
|
|
3975
|
+
between: [String]
|
|
3976
|
+
beginsWith: String
|
|
3977
|
+
in: [String]
|
|
3978
|
+
notIn: [String]
|
|
3979
|
+
}
|
|
3980
|
+
|
|
3981
|
+
input ModelSubscriptionIntInput {
|
|
3982
|
+
ne: Int
|
|
3983
|
+
eq: Int
|
|
3984
|
+
le: Int
|
|
3985
|
+
lt: Int
|
|
3986
|
+
ge: Int
|
|
3987
|
+
gt: Int
|
|
3988
|
+
between: [Int]
|
|
3989
|
+
in: [Int]
|
|
3990
|
+
notIn: [Int]
|
|
3991
|
+
}
|
|
3992
|
+
|
|
3993
|
+
input ModelSubscriptionFloatInput {
|
|
3994
|
+
ne: Float
|
|
3995
|
+
eq: Float
|
|
3996
|
+
le: Float
|
|
3997
|
+
lt: Float
|
|
3998
|
+
ge: Float
|
|
3999
|
+
gt: Float
|
|
4000
|
+
between: [Float]
|
|
4001
|
+
in: [Float]
|
|
4002
|
+
notIn: [Float]
|
|
4003
|
+
}
|
|
4004
|
+
|
|
4005
|
+
input ModelSubscriptionBooleanInput {
|
|
4006
|
+
ne: Boolean
|
|
4007
|
+
eq: Boolean
|
|
4008
|
+
}
|
|
4009
|
+
|
|
4010
|
+
input ModelSubscriptionIDInput {
|
|
4011
|
+
ne: ID
|
|
4012
|
+
eq: ID
|
|
4013
|
+
le: ID
|
|
4014
|
+
lt: ID
|
|
4015
|
+
ge: ID
|
|
4016
|
+
gt: ID
|
|
4017
|
+
contains: ID
|
|
4018
|
+
notContains: ID
|
|
4019
|
+
between: [ID]
|
|
4020
|
+
beginsWith: ID
|
|
4021
|
+
in: [ID]
|
|
4022
|
+
notIn: [ID]
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4025
|
+
enum ModelAttributeTypes {
|
|
4026
|
+
binary
|
|
4027
|
+
binarySet
|
|
4028
|
+
bool
|
|
4029
|
+
list
|
|
4030
|
+
map
|
|
4031
|
+
number
|
|
4032
|
+
numberSet
|
|
4033
|
+
string
|
|
4034
|
+
stringSet
|
|
4035
|
+
_null
|
|
4036
|
+
}
|
|
4037
|
+
|
|
4038
|
+
input ModelSizeInput {
|
|
4039
|
+
ne: Int
|
|
4040
|
+
eq: Int
|
|
4041
|
+
le: Int
|
|
4042
|
+
lt: Int
|
|
4043
|
+
ge: Int
|
|
4044
|
+
gt: Int
|
|
4045
|
+
between: [Int]
|
|
4046
|
+
}
|
|
4047
|
+
|
|
4048
|
+
enum ModelSortDirection {
|
|
4049
|
+
ASC
|
|
4050
|
+
DESC
|
|
4051
|
+
}
|
|
4052
|
+
|
|
4053
|
+
"
|
|
4054
|
+
`;
|
|
4055
|
+
|
|
4056
|
+
exports[`ModelTransformer: should successfully transform simple non-capitalized Model/Embeddable type (non-model) name schema 1`] = `
|
|
4057
|
+
"
|
|
4058
|
+
type modelType {
|
|
4059
|
+
id: ID!
|
|
4060
|
+
title: String!
|
|
4061
|
+
nonModelTypeValue: nonModelType
|
|
4062
|
+
createdAt: AWSDateTime!
|
|
4063
|
+
updatedAt: AWSDateTime!
|
|
4064
|
+
}
|
|
4065
|
+
|
|
4066
|
+
type nonModelType {
|
|
4067
|
+
id: ID!
|
|
4068
|
+
title: String!
|
|
4069
|
+
}
|
|
4070
|
+
|
|
4071
|
+
input ModelStringInput {
|
|
4072
|
+
ne: String
|
|
4073
|
+
eq: String
|
|
4074
|
+
le: String
|
|
4075
|
+
lt: String
|
|
4076
|
+
ge: String
|
|
4077
|
+
gt: String
|
|
4078
|
+
contains: String
|
|
4079
|
+
notContains: String
|
|
4080
|
+
between: [String]
|
|
4081
|
+
beginsWith: String
|
|
4082
|
+
attributeExists: Boolean
|
|
4083
|
+
attributeType: ModelAttributeTypes
|
|
4084
|
+
size: ModelSizeInput
|
|
4085
|
+
}
|
|
4086
|
+
|
|
4087
|
+
input ModelIntInput {
|
|
4088
|
+
ne: Int
|
|
4089
|
+
eq: Int
|
|
4090
|
+
le: Int
|
|
4091
|
+
lt: Int
|
|
4092
|
+
ge: Int
|
|
4093
|
+
gt: Int
|
|
4094
|
+
between: [Int]
|
|
4095
|
+
attributeExists: Boolean
|
|
4096
|
+
attributeType: ModelAttributeTypes
|
|
4097
|
+
}
|
|
4098
|
+
|
|
4099
|
+
input ModelFloatInput {
|
|
4100
|
+
ne: Float
|
|
4101
|
+
eq: Float
|
|
4102
|
+
le: Float
|
|
4103
|
+
lt: Float
|
|
4104
|
+
ge: Float
|
|
4105
|
+
gt: Float
|
|
4106
|
+
between: [Float]
|
|
4107
|
+
attributeExists: Boolean
|
|
4108
|
+
attributeType: ModelAttributeTypes
|
|
4109
|
+
}
|
|
4110
|
+
|
|
4111
|
+
input ModelBooleanInput {
|
|
4112
|
+
ne: Boolean
|
|
4113
|
+
eq: Boolean
|
|
4114
|
+
attributeExists: Boolean
|
|
4115
|
+
attributeType: ModelAttributeTypes
|
|
4116
|
+
}
|
|
4117
|
+
|
|
4118
|
+
input ModelIDInput {
|
|
4119
|
+
ne: ID
|
|
4120
|
+
eq: ID
|
|
4121
|
+
le: ID
|
|
4122
|
+
lt: ID
|
|
4123
|
+
ge: ID
|
|
4124
|
+
gt: ID
|
|
4125
|
+
contains: ID
|
|
4126
|
+
notContains: ID
|
|
4127
|
+
between: [ID]
|
|
4128
|
+
beginsWith: ID
|
|
4129
|
+
attributeExists: Boolean
|
|
4130
|
+
attributeType: ModelAttributeTypes
|
|
4131
|
+
size: ModelSizeInput
|
|
4132
|
+
}
|
|
4133
|
+
|
|
4134
|
+
input ModelSubscriptionStringInput {
|
|
4135
|
+
ne: String
|
|
4136
|
+
eq: String
|
|
4137
|
+
le: String
|
|
4138
|
+
lt: String
|
|
4139
|
+
ge: String
|
|
4140
|
+
gt: String
|
|
4141
|
+
contains: String
|
|
4142
|
+
notContains: String
|
|
4143
|
+
between: [String]
|
|
4144
|
+
beginsWith: String
|
|
4145
|
+
in: [String]
|
|
4146
|
+
notIn: [String]
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4149
|
+
input ModelSubscriptionIntInput {
|
|
4150
|
+
ne: Int
|
|
4151
|
+
eq: Int
|
|
4152
|
+
le: Int
|
|
4153
|
+
lt: Int
|
|
4154
|
+
ge: Int
|
|
4155
|
+
gt: Int
|
|
4156
|
+
between: [Int]
|
|
4157
|
+
in: [Int]
|
|
4158
|
+
notIn: [Int]
|
|
4159
|
+
}
|
|
4160
|
+
|
|
4161
|
+
input ModelSubscriptionFloatInput {
|
|
4162
|
+
ne: Float
|
|
4163
|
+
eq: Float
|
|
4164
|
+
le: Float
|
|
4165
|
+
lt: Float
|
|
4166
|
+
ge: Float
|
|
4167
|
+
gt: Float
|
|
4168
|
+
between: [Float]
|
|
4169
|
+
in: [Float]
|
|
4170
|
+
notIn: [Float]
|
|
4171
|
+
}
|
|
4172
|
+
|
|
4173
|
+
input ModelSubscriptionBooleanInput {
|
|
4174
|
+
ne: Boolean
|
|
4175
|
+
eq: Boolean
|
|
4176
|
+
}
|
|
4177
|
+
|
|
4178
|
+
input ModelSubscriptionIDInput {
|
|
4179
|
+
ne: ID
|
|
4180
|
+
eq: ID
|
|
4181
|
+
le: ID
|
|
4182
|
+
lt: ID
|
|
4183
|
+
ge: ID
|
|
4184
|
+
gt: ID
|
|
4185
|
+
contains: ID
|
|
4186
|
+
notContains: ID
|
|
4187
|
+
between: [ID]
|
|
4188
|
+
beginsWith: ID
|
|
4189
|
+
in: [ID]
|
|
4190
|
+
notIn: [ID]
|
|
4191
|
+
}
|
|
4192
|
+
|
|
4193
|
+
enum ModelAttributeTypes {
|
|
4194
|
+
binary
|
|
4195
|
+
binarySet
|
|
4196
|
+
bool
|
|
4197
|
+
list
|
|
4198
|
+
map
|
|
4199
|
+
number
|
|
4200
|
+
numberSet
|
|
4201
|
+
string
|
|
4202
|
+
stringSet
|
|
4203
|
+
_null
|
|
4204
|
+
}
|
|
4205
|
+
|
|
4206
|
+
input ModelSizeInput {
|
|
4207
|
+
ne: Int
|
|
4208
|
+
eq: Int
|
|
4209
|
+
le: Int
|
|
4210
|
+
lt: Int
|
|
4211
|
+
ge: Int
|
|
4212
|
+
gt: Int
|
|
4213
|
+
between: [Int]
|
|
4214
|
+
}
|
|
4215
|
+
|
|
4216
|
+
enum ModelSortDirection {
|
|
4217
|
+
ASC
|
|
4218
|
+
DESC
|
|
4219
|
+
}
|
|
4220
|
+
|
|
4221
|
+
input NonModelTypeInput {
|
|
4222
|
+
id: ID
|
|
4223
|
+
title: String!
|
|
4224
|
+
}
|
|
4225
|
+
|
|
4226
|
+
type ModelModelTypeConnection {
|
|
4227
|
+
items: [modelType]!
|
|
4228
|
+
nextToken: String
|
|
4229
|
+
}
|
|
4230
|
+
|
|
4231
|
+
input ModelModelTypeFilterInput {
|
|
4232
|
+
id: ModelIDInput
|
|
4233
|
+
title: ModelStringInput
|
|
4234
|
+
and: [ModelModelTypeFilterInput]
|
|
4235
|
+
or: [ModelModelTypeFilterInput]
|
|
4236
|
+
not: ModelModelTypeFilterInput
|
|
4237
|
+
}
|
|
4238
|
+
|
|
4239
|
+
type Query {
|
|
4240
|
+
getModelType(id: ID!): modelType
|
|
4241
|
+
listModelTypes(filter: ModelModelTypeFilterInput, limit: Int, nextToken: String): ModelModelTypeConnection
|
|
4242
|
+
}
|
|
4243
|
+
|
|
4244
|
+
input ModelModelTypeConditionInput {
|
|
4245
|
+
title: ModelStringInput
|
|
4246
|
+
and: [ModelModelTypeConditionInput]
|
|
4247
|
+
or: [ModelModelTypeConditionInput]
|
|
4248
|
+
not: ModelModelTypeConditionInput
|
|
4249
|
+
}
|
|
4250
|
+
|
|
4251
|
+
input CreateModelTypeInput {
|
|
4252
|
+
id: ID
|
|
4253
|
+
title: String!
|
|
4254
|
+
nonModelTypeValue: NonModelTypeInput
|
|
4255
|
+
}
|
|
4256
|
+
|
|
4257
|
+
input UpdateModelTypeInput {
|
|
4258
|
+
id: ID!
|
|
4259
|
+
title: String
|
|
4260
|
+
nonModelTypeValue: NonModelTypeInput
|
|
4261
|
+
}
|
|
4262
|
+
|
|
4263
|
+
input DeleteModelTypeInput {
|
|
4264
|
+
id: ID!
|
|
4265
|
+
}
|
|
4266
|
+
|
|
4267
|
+
type Mutation {
|
|
4268
|
+
createModelType(input: CreateModelTypeInput!, condition: ModelModelTypeConditionInput): modelType
|
|
4269
|
+
updateModelType(input: UpdateModelTypeInput!, condition: ModelModelTypeConditionInput): modelType
|
|
4270
|
+
deleteModelType(input: DeleteModelTypeInput!, condition: ModelModelTypeConditionInput): modelType
|
|
4271
|
+
}
|
|
4272
|
+
|
|
4273
|
+
input ModelSubscriptionModelTypeFilterInput {
|
|
4274
|
+
id: ModelSubscriptionIDInput
|
|
4275
|
+
title: ModelSubscriptionStringInput
|
|
4276
|
+
and: [ModelSubscriptionModelTypeFilterInput]
|
|
4277
|
+
or: [ModelSubscriptionModelTypeFilterInput]
|
|
4278
|
+
}
|
|
4279
|
+
|
|
4280
|
+
type Subscription {
|
|
4281
|
+
onCreateModelType(filter: ModelSubscriptionModelTypeFilterInput): modelType @aws_subscribe(mutations: [\\"createModelType\\"])
|
|
4282
|
+
onUpdateModelType(filter: ModelSubscriptionModelTypeFilterInput): modelType @aws_subscribe(mutations: [\\"updateModelType\\"])
|
|
4283
|
+
onDeleteModelType(filter: ModelSubscriptionModelTypeFilterInput): modelType @aws_subscribe(mutations: [\\"deleteModelType\\"])
|
|
4284
|
+
}
|
|
4285
|
+
|
|
4286
|
+
"
|
|
4287
|
+
`;
|
|
4288
|
+
|
|
3896
4289
|
exports[`ModelTransformer: should support timestamp parameters when generating resolvers and output schema 1`] = `
|
|
3897
4290
|
"
|
|
3898
4291
|
type Post {
|
|
@@ -41,6 +41,51 @@ describe('ModelTransformer: ', () => {
|
|
|
41
41
|
parse(out.schema);
|
|
42
42
|
});
|
|
43
43
|
|
|
44
|
+
// should successfully transform simple Embeddable type (non-model) schema
|
|
45
|
+
it('should successfully transform simple Embeddable type (non-model) schema', async () => {
|
|
46
|
+
const validSchema = `
|
|
47
|
+
type NonModelType {
|
|
48
|
+
id: ID!
|
|
49
|
+
title: String!
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
const transformer = new GraphQLTransform({
|
|
53
|
+
transformers: [new ModelTransformer()],
|
|
54
|
+
featureFlags,
|
|
55
|
+
});
|
|
56
|
+
const out = transformer.transform(validSchema);
|
|
57
|
+
expect(out).toBeDefined();
|
|
58
|
+
|
|
59
|
+
validateModelSchema(parse(out.schema));
|
|
60
|
+
parse(out.schema);
|
|
61
|
+
expect(out.schema).toMatchSnapshot();
|
|
62
|
+
});
|
|
63
|
+
// should successfully transform simple non-capitalized Embeddable type (non-model) name schema
|
|
64
|
+
it('should successfully transform simple non-capitalized Model/Embeddable type (non-model) name schema', async () => {
|
|
65
|
+
const alsoValidSchema = `
|
|
66
|
+
type modelType @model {
|
|
67
|
+
id: ID!
|
|
68
|
+
title: String!
|
|
69
|
+
nonModelTypeValue: nonModelType
|
|
70
|
+
}
|
|
71
|
+
type nonModelType {
|
|
72
|
+
id: ID!
|
|
73
|
+
title: String!
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
const transformer = new GraphQLTransform({
|
|
77
|
+
transformers: [new ModelTransformer()],
|
|
78
|
+
featureFlags,
|
|
79
|
+
});
|
|
80
|
+
const out = transformer.transform(alsoValidSchema);
|
|
81
|
+
expect(out).toBeDefined();
|
|
82
|
+
|
|
83
|
+
validateModelSchema(parse(out.schema));
|
|
84
|
+
parse(out.schema);
|
|
85
|
+
expect(out.schema).toMatchSnapshot();
|
|
86
|
+
expect(out.schema).toContain("input NonModelTypeInput")
|
|
87
|
+
});
|
|
88
|
+
|
|
44
89
|
it('should support custom query overrides', () => {
|
|
45
90
|
const validSchema = `type Post @model(queries: { get: "customGetPost", list: "customListPost" }) {
|
|
46
91
|
id: ID!
|
|
@@ -63,6 +63,7 @@ import {
|
|
|
63
63
|
SyncResourceIDs,
|
|
64
64
|
toCamelCase,
|
|
65
65
|
toPascalCase,
|
|
66
|
+
toUpper,
|
|
66
67
|
} from 'graphql-transformer-common';
|
|
67
68
|
import {
|
|
68
69
|
addDirectivesToOperation,
|
|
@@ -1084,7 +1085,7 @@ export class ModelTransformer extends TransformerModelBase implements Transforme
|
|
|
1084
1085
|
|
|
1085
1086
|
private isModelField = (name: string): boolean => (!!this.typesWithModelDirective.has(name));
|
|
1086
1087
|
|
|
1087
|
-
private getNonModelInputObjectName = (name: string): string => `${name}Input`;
|
|
1088
|
+
private getNonModelInputObjectName = (name: string): string => `${toUpper(name)}Input`;
|
|
1088
1089
|
|
|
1089
1090
|
/**
|
|
1090
1091
|
* Model directive automatically adds id, created and updated time stamps to the filed, if they are configured
|