Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: generate list types as non-null #8166

Merged
merged 8 commits into from
Oct 22, 2021
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