graphql-connection-transformer
Advanced tools
Comparing version 1.0.12 to 1.0.13-publish-test.0
@@ -6,2 +6,13 @@ # Change Log | ||
<a name="1.0.13-publish-test.0"></a> | ||
## [1.0.13-publish-test.0](https://github.com/aws-amplify/amplify-cli/compare/graphql-connection-transformer@1.0.12...graphql-connection-transformer@1.0.13-publish-test.0) (2018-10-03) | ||
### Bug Fixes | ||
* **graphql-connection-transformer:** Remove unused types ([87c3e0a](https://github.com/aws-amplify/amplify-cli/commit/87c3e0a)) | ||
<a name="1.0.12"></a> | ||
@@ -8,0 +19,0 @@ ## [1.0.12](https://github.com/aws-amplify/amplify-cli/compare/graphql-connection-transformer@1.0.11...graphql-connection-transformer@1.0.12) (2018-08-23) |
@@ -173,2 +173,24 @@ "use strict"; | ||
}); | ||
test('Test ModelConnectionTransformer many to many should fail due to missing other "name"', function () { | ||
var validSchema = "\n type Post @model {\n id: ID!\n things: [Thing!] @connection\n }\n\n type Thing @model(queries: null, mutations: null) {\n id: ID!\n }\n "; | ||
var transformer = new graphql_transformer_core_1.default({ | ||
transformers: [ | ||
new graphql_appsync_transformer_1.default(), | ||
new graphql_dynamodb_transformer_1.default(), | ||
new ModelConnectionTransformer_1.ModelConnectionTransformer() | ||
] | ||
}); | ||
var out = transformer.transform(validSchema); | ||
expect(out).toBeDefined(); | ||
expect(out.Resources[graphql_transformer_common_1.ResolverResourceIDs.ResolverResourceID('Post', 'things')]).toBeTruthy(); | ||
var schemaDoc = graphql_1.parse(out.Resources[graphql_transformer_common_1.ResourceConstants.RESOURCES.GraphQLSchemaLogicalID].Properties.Definition); | ||
var postType = getObjectType(schemaDoc, 'Post'); | ||
var postConnection = getObjectType(schemaDoc, 'ModelPostConnection'); | ||
var thingConnection = getObjectType(schemaDoc, 'ModelThingConnection'); | ||
var thingFilterInput = getInputType(schemaDoc, 'ModelThingFilterInput'); | ||
expect(thingFilterInput).toBeDefined(); | ||
expect(postType).toBeDefined(); | ||
expect(thingConnection).toBeDefined(); | ||
expect(postConnection).toBeDefined(); | ||
}); | ||
function expectFields(type, fields) { | ||
@@ -175,0 +197,0 @@ var _loop_1 = function (fieldName) { |
@@ -15,3 +15,3 @@ "use strict"; | ||
var updatedFields = input.fields.concat([ | ||
graphql_transformer_common_1.makeArg(connectionFieldName, nonNull ? graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType('ID')) : graphql_transformer_common_1.makeNamedType('ID')) | ||
graphql_transformer_common_1.makeInputValueDefinition(connectionFieldName, nonNull ? graphql_transformer_common_1.makeNonNullType(graphql_transformer_common_1.makeNamedType('ID')) : graphql_transformer_common_1.makeNamedType('ID')) | ||
]); | ||
@@ -23,3 +23,3 @@ return __assign({}, input, { fields: updatedFields }); | ||
var updatedFields = input.fields.concat([ | ||
graphql_transformer_common_1.makeArg(connectionFieldName, graphql_transformer_common_1.makeNamedType('ID')) | ||
graphql_transformer_common_1.makeInputValueDefinition(connectionFieldName, graphql_transformer_common_1.makeNamedType('ID')) | ||
]); | ||
@@ -26,0 +26,0 @@ return __assign({}, input, { fields: updatedFields }); |
@@ -223,3 +223,3 @@ "use strict"; | ||
} | ||
this.generateFilterInputs(ctx, parent); | ||
this.generateFilterInputs(ctx, returnType); | ||
} | ||
@@ -226,0 +226,0 @@ else { |
{ | ||
"name": "graphql-connection-transformer", | ||
"version": "1.0.12", | ||
"version": "1.0.13-publish-test.0", | ||
"description": "An AppSync model transform for connecting objects.", | ||
@@ -9,4 +9,3 @@ "main": "lib/index.js", | ||
"build": "tsc", | ||
"clean": "rm -rf ./lib", | ||
"lint": "tslint -p ./tslint.json" | ||
"clean": "rm -rf ./lib" | ||
}, | ||
@@ -23,6 +22,6 @@ "keywords": [ | ||
"graphql": "^0.13.2", | ||
"graphql-dynamodb-transformer": "^1.0.12", | ||
"graphql-mapping-template": "^1.0.12", | ||
"graphql-transformer-common": "^1.0.12", | ||
"graphql-transformer-core": "^1.0.12" | ||
"graphql-dynamodb-transformer": "^1.0.13-publish-test.0", | ||
"graphql-mapping-template": "^1.0.13-publish-test.0", | ||
"graphql-transformer-common": "^1.0.13-publish-test.0", | ||
"graphql-transformer-core": "^1.0.13-publish-test.0" | ||
}, | ||
@@ -34,3 +33,3 @@ "devDependencies": { | ||
"aws-sdk": "^2.259.1", | ||
"graphql-appsync-transformer": "^1.0.12", | ||
"graphql-appsync-transformer": "^1.0.13-publish-test.0", | ||
"jest": "^23.1.0", | ||
@@ -37,0 +36,0 @@ "ts-jest": "^22.4.6", |
@@ -261,2 +261,34 @@ import { | ||
test('Test ModelConnectionTransformer many to many should fail due to missing other "name"', () => { | ||
const validSchema = ` | ||
type Post @model { | ||
id: ID! | ||
things: [Thing!] @connection | ||
} | ||
type Thing @model(queries: null, mutations: null) { | ||
id: ID! | ||
} | ||
` | ||
const transformer = new GraphQLTransform({ | ||
transformers: [ | ||
new AppSyncTransformer(), | ||
new DynamoDBModelTransformer(), | ||
new ModelConnectionTransformer() | ||
] | ||
}) | ||
const out = transformer.transform(validSchema); | ||
expect(out).toBeDefined() | ||
expect(out.Resources[ResolverResourceIDs.ResolverResourceID('Post', 'things')]).toBeTruthy() | ||
const schemaDoc = parse(out.Resources[ResourceConstants.RESOURCES.GraphQLSchemaLogicalID].Properties.Definition) | ||
const postType = getObjectType(schemaDoc, 'Post') | ||
const postConnection = getObjectType(schemaDoc, 'ModelPostConnection') | ||
const thingConnection = getObjectType(schemaDoc, 'ModelThingConnection') | ||
const thingFilterInput = getInputType(schemaDoc, 'ModelThingFilterInput') | ||
expect(thingFilterInput).toBeDefined() | ||
expect(postType).toBeDefined() | ||
expect(thingConnection).toBeDefined() | ||
expect(postConnection).toBeDefined() | ||
}); | ||
function expectFields(type: ObjectTypeDefinitionNode, fields: string[]) { | ||
@@ -263,0 +295,0 @@ for (const fieldName of fields) { |
import { InputObjectTypeDefinitionNode } from 'graphql' | ||
import { makeArg, makeNonNullType, makeNamedType } from 'graphql-transformer-common'; | ||
import { makeInputValueDefinition, makeNonNullType, makeNamedType } from 'graphql-transformer-common'; | ||
@@ -11,3 +11,3 @@ export function updateCreateInputWithConnectionField( | ||
...input.fields, | ||
makeArg(connectionFieldName, nonNull ? makeNonNullType(makeNamedType('ID')) : makeNamedType('ID')) | ||
makeInputValueDefinition(connectionFieldName, nonNull ? makeNonNullType(makeNamedType('ID')) : makeNamedType('ID')) | ||
] | ||
@@ -26,3 +26,3 @@ return { | ||
...input.fields, | ||
makeArg(connectionFieldName, makeNamedType('ID')) | ||
makeInputValueDefinition(connectionFieldName, makeNamedType('ID')) | ||
] | ||
@@ -29,0 +29,0 @@ return { |
@@ -23,19 +23,2 @@ import { Transformer, TransformerContext, InvalidDirectiveError } from 'graphql-transformer-core' | ||
interface QueryNameMap { | ||
get?: string; | ||
list?: string; | ||
query?: string; | ||
} | ||
interface MutationNameMap { | ||
create?: string; | ||
update?: string; | ||
delete?: string; | ||
} | ||
interface ModelDirectiveArgs { | ||
queries?: QueryNameMap, | ||
mutations?: MutationNameMap | ||
} | ||
function makeConnectionAttributeName(type: string, field?: string) { | ||
@@ -308,3 +291,3 @@ return field ? toCamelCase([type, field, 'id']) : toCamelCase([type, 'id']) | ||
this.generateFilterInputs(ctx, parent) | ||
this.generateFilterInputs(ctx, returnType) | ||
} else { | ||
@@ -311,0 +294,0 @@ throw new InvalidDirectiveError(`Could not find a object or interface type named ${parent.name.value}.`) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
108406
1490
2