Skip to content

Commit

Permalink
feat: generate list types as non-null (#8166)
Browse files Browse the repository at this point in the history
* feat: generate list types as non-null

* test: update more snapshots

* fix: make corresponding change in v2 transformer

* fix: non null lists in v2 transformer

* chore: force cci rerun

* test: update one more snapshot

* test: who knew there were so many snapshots to update
  • Loading branch information
edwardfoyle authored Oct 22, 2021
1 parent 26efb7a commit 93786c1
Show file tree
Hide file tree
Showing 18 changed files with 1,254 additions and 1,209 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ enum ModelSortDirection {
}
type ModelPostConnection {
items: [Post]
items: [Post!]!
nextToken: String
}
Expand Down
2 changes: 1 addition & 1 deletion packages/amplify-graphql-index-transformer/src/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ function generateModelXConnectionType(config: IndexDirectiveConfiguration, ctx:
let connectionTypeExtension = blankObjectExtension(tableXConnectionName);

connectionTypeExtension = extensionWithFields(connectionTypeExtension, [
makeField('items', [], makeListType(makeNamedType(tableXConnectionName))),
makeField('items', [], makeNonNullType(makeListType(makeNonNullType(makeNamedType(object.name.value))))),
]);
connectionTypeExtension = extensionWithFields(connectionTypeExtension, [makeField('nextToken', [], makeNamedType('String'))]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ enum ModelSortDirection {
}

type ModelTestConnection {
items: [Test]
items: [Test!]!
nextToken: String
}

Expand Down Expand Up @@ -162,7 +162,7 @@ type Subscription {
}

type ModelEmailConnection {
items: [Email]
items: [Email!]!
nextToken: String
}

Expand Down Expand Up @@ -356,7 +356,7 @@ input EntityMetadataInput {
}

type ModelPostConnection {
items: [Post]
items: [Post!]!
nextToken: String
}

Expand Down Expand Up @@ -463,7 +463,7 @@ type Subscription {
}

type ModelAuthorConnection {
items: [Author]
items: [Author!]!
nextToken: String
}

Expand Down Expand Up @@ -501,7 +501,7 @@ input DeleteAuthorInput {
}

type ModelRequireConnection {
items: [Require]
items: [Require!]!
nextToken: String
}

Expand Down Expand Up @@ -539,7 +539,7 @@ input DeleteRequireInput {
}

type ModelCommentConnection {
items: [Comment]
items: [Comment!]!
nextToken: String
}

Expand Down Expand Up @@ -12153,7 +12153,7 @@ enum ModelSortDirection {
}

type ModelPostConnection {
items: [Post]
items: [Post!]!
nextToken: String
}

Expand Down Expand Up @@ -12690,7 +12690,7 @@ enum ModelSortDirection {
}

type ModelPostConnection {
items: [Post]
items: [Post!]!
nextToken: String
}

Expand Down Expand Up @@ -13050,7 +13050,7 @@ enum ModelSortDirection {
}

type ModelPostConnection {
items: [Post]
items: [Post!]!
nextToken: String
}

Expand Down Expand Up @@ -13404,7 +13404,7 @@ enum ModelSortDirection {
}

type ModelPostConnection {
items: [Post]
items: [Post!]!
nextToken: String
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const makeListQueryFilterInput = (
export const makeListQueryModel = (type: ObjectTypeDefinitionNode, modelName: string, isSyncEnabled: boolean): ObjectTypeDefinitionNode => {
const outputType = ObjectDefinitionWrapper.create(modelName);

outputType.addField(FieldWrapper.create('items', type.name.value, true, true));
outputType.addField(FieldWrapper.create('items', type.name.value, false, true));
outputType.addField(FieldWrapper.create('nextToken', 'String', true, false));

if (isSyncEnabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export class FieldWrapper extends GenericFieldWrapper {
field.makeNonNullable();
}
if (isList) {
field.wrapListType();
field.wrapListType().makeNonNullable();
}
return field;
};
Expand Down
Loading

0 comments on commit 93786c1

Please sign in to comment.