From a3023857956af67b820f1ee3296243de6510ca2a Mon Sep 17 00:00:00 2001 From: Ola Okelola Date: Tue, 19 Jul 2022 15:08:22 -0700 Subject: [PATCH] fix id field of graphql mutations i've been meaning to do this for a while meant to do this as part of the first batch of v1 changes. will just be one more breaking change in the list --- docs/docs/migration-v01/migration-guide.md | 3 +- .../mutations/address/address_delete_type.ts | 8 +-- .../mutations/address/address_edit_type.ts | 6 +-- .../event_activity_add_invite_type.ts | 6 +-- .../event_activity_delete_type.ts | 8 +-- .../event_activity_edit_type.ts | 6 +-- .../event_activity_remove_invite_type.ts | 6 +-- .../event_activity_rsvp_status_edit_type.ts | 6 +-- .../mutations/guest/guest_delete_type.ts | 8 +-- .../mutations/guest/guest_edit_type.ts | 6 +-- .../guest_group/guest_group_delete_type.ts | 8 +-- .../guest_group/guest_group_edit_type.ts | 6 +-- .../backend/src/graphql/generated/schema.gql | 41 ++++++++------- .../graphql/tests/event_activity_type.test.ts | 6 +-- .../mutations/contact/contact_delete_type.ts | 8 +-- .../mutations/contact/contact_edit_type.ts | 6 +-- .../contact_email_delete_type.ts | 8 +-- .../contact_email/contact_email_edit_type.ts | 6 +-- .../contact_phone_number_delete_type.ts | 8 +-- .../contact_phone_number_edit_type.ts | 6 +-- .../mutations/event/event_add_host_type.ts | 6 +-- .../mutations/event/event_delete_type.ts | 8 +-- .../mutations/event/event_edit_type.ts | 6 +-- .../mutations/event/event_remove_host_type.ts | 6 +-- .../event/event_rsvp_status_edit_type.ts | 6 +-- .../user/confirm_email_address_edit_type.ts | 6 +-- .../user/confirm_phone_number_edit_type.ts | 6 +-- .../mutations/user/email_address_edit_type.ts | 6 +-- .../mutations/user/phone_number_edit_type.ts | 6 +-- .../mutations/user/user_delete_2_type.ts | 8 +-- .../mutations/user/user_delete_type.ts | 8 +-- .../mutations/user/user_edit_type.ts | 6 +-- .../simple/src/graphql/generated/schema.gql | 36 ++++++------- .../mutations/tests/user_mutations.test.ts | 12 ++--- .../src/graphql/tests/event_type.test.ts | 8 +-- .../mutations/account/delete_account_type.ts | 11 ++-- .../mutations/account/edit_account_type.ts | 6 +-- .../mutations/todo/add_todo_tag_type.ts | 6 +-- .../mutations/todo/change_todo_status_type.ts | 6 +-- .../mutations/todo/delete_todo_type.ts | 8 +-- .../mutations/todo/remove_todo_tag_type.ts | 6 +-- .../mutations/todo/rename_todo_type.ts | 6 +-- .../src/graphql/generated/schema.gql | 14 ++--- .../src/graphql/tests/todo.test.ts | 6 +-- internal/codegen/codegenapi/api.go | 6 +++ internal/field/field.go | 14 +++++ internal/graphql/generate_ts_code.go | 51 +++++++++++++------ 47 files changed, 240 insertions(+), 200 deletions(-) diff --git a/docs/docs/migration-v01/migration-guide.md b/docs/docs/migration-v01/migration-guide.md index 0f70965ed..82360964d 100644 --- a/docs/docs/migration-v01/migration-guide.md +++ b/docs/docs/migration-v01/migration-guide.md @@ -33,7 +33,8 @@ fields: { * `Foo.loadMany` API changes from returning list to Map which is a breaking change * moving all generated files to `src/ent/generated` and `src/graphql/generated` so easier to see in PRs and VSCode * enums are now prefixed with schemaName -* and more +* change id field in edit and delete graphql mutations from `fooID` to `id` +* and more ## Migration steps diff --git a/examples/ent-rsvp/backend/src/graphql/generated/mutations/address/address_delete_type.ts b/examples/ent-rsvp/backend/src/graphql/generated/mutations/address/address_delete_type.ts index c2628200c..6e375ca1c 100644 --- a/examples/ent-rsvp/backend/src/graphql/generated/mutations/address/address_delete_type.ts +++ b/examples/ent-rsvp/backend/src/graphql/generated/mutations/address/address_delete_type.ts @@ -15,7 +15,7 @@ import { mustDecodeIDFromGQLID } from "@snowtop/ent/graphql"; import DeleteAddressAction from "src/ent/address/actions/delete_address_action"; interface customAddressDeleteInput { - addressID: string; + id: string; } interface AddressDeletePayload { @@ -25,7 +25,7 @@ interface AddressDeletePayload { export const AddressDeleteInputType = new GraphQLInputObjectType({ name: "AddressDeleteInput", fields: (): GraphQLInputFieldConfigMap => ({ - addressID: { + id: { description: "id of Address", type: new GraphQLNonNull(GraphQLID), }, @@ -61,8 +61,8 @@ export const AddressDeleteType: GraphQLFieldConfig< ): Promise => { await DeleteAddressAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.addressID), + mustDecodeIDFromGQLID(input.id), ); - return { deletedAddressID: input.addressID }; + return { deletedAddressID: input.id }; }, }; diff --git a/examples/ent-rsvp/backend/src/graphql/generated/mutations/address/address_edit_type.ts b/examples/ent-rsvp/backend/src/graphql/generated/mutations/address/address_edit_type.ts index 02d04b598..284da5db4 100644 --- a/examples/ent-rsvp/backend/src/graphql/generated/mutations/address/address_edit_type.ts +++ b/examples/ent-rsvp/backend/src/graphql/generated/mutations/address/address_edit_type.ts @@ -23,7 +23,7 @@ import EditAddressAction, { import { AddressType } from "src/graphql/resolvers/"; interface customAddressEditInput extends AddressEditInput { - addressID: string; + id: string; ownerID?: string; } @@ -34,7 +34,7 @@ interface AddressEditPayload { export const AddressEditInputType = new GraphQLInputObjectType({ name: "AddressEditInput", fields: (): GraphQLInputFieldConfigMap => ({ - addressID: { + id: { description: "id of Address", type: new GraphQLNonNull(GraphQLID), }, @@ -91,7 +91,7 @@ export const AddressEditType: GraphQLFieldConfig< ): Promise => { const address = await EditAddressAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.addressID), + mustDecodeIDFromGQLID(input.id), { street: input.street, city: input.city, diff --git a/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_add_invite_type.ts b/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_add_invite_type.ts index f919c6eed..530c6a857 100644 --- a/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_add_invite_type.ts +++ b/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_add_invite_type.ts @@ -17,7 +17,7 @@ import EventActivityAddInviteAction from "src/ent/event_activity/actions/event_a import { EventActivityType } from "src/graphql/resolvers/"; interface customEventActivityAddInviteInput { - eventActivityID: string; + id: string; inviteID: string; } @@ -28,7 +28,7 @@ interface EventActivityAddInvitePayload { export const EventActivityAddInviteInputType = new GraphQLInputObjectType({ name: "EventActivityAddInviteInput", fields: (): GraphQLInputFieldConfigMap => ({ - eventActivityID: { + id: { description: "id of EventActivity", type: new GraphQLNonNull(GraphQLID), }, @@ -70,7 +70,7 @@ export const EventActivityAddInviteType: GraphQLFieldConfig< ): Promise => { const eventActivity = await EventActivityAddInviteAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.eventActivityID), + mustDecodeIDFromGQLID(input.id), mustDecodeIDFromGQLID(input.inviteID), ); return { eventActivity: eventActivity }; diff --git a/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_delete_type.ts b/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_delete_type.ts index fa00f0c3e..f2f43fa48 100644 --- a/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_delete_type.ts +++ b/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_delete_type.ts @@ -15,7 +15,7 @@ import { mustDecodeIDFromGQLID } from "@snowtop/ent/graphql"; import DeleteEventActivityAction from "src/ent/event_activity/actions/delete_event_activity_action"; interface customEventActivityDeleteInput { - eventActivityID: string; + id: string; } interface EventActivityDeletePayload { @@ -25,7 +25,7 @@ interface EventActivityDeletePayload { export const EventActivityDeleteInputType = new GraphQLInputObjectType({ name: "EventActivityDeleteInput", fields: (): GraphQLInputFieldConfigMap => ({ - eventActivityID: { + id: { description: "id of EventActivity", type: new GraphQLNonNull(GraphQLID), }, @@ -64,8 +64,8 @@ export const EventActivityDeleteType: GraphQLFieldConfig< ): Promise => { await DeleteEventActivityAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.eventActivityID), + mustDecodeIDFromGQLID(input.id), ); - return { deletedEventActivityID: input.eventActivityID }; + return { deletedEventActivityID: input.id }; }, }; diff --git a/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_edit_type.ts b/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_edit_type.ts index 7464a2f7a..35fc463d2 100644 --- a/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_edit_type.ts +++ b/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_edit_type.ts @@ -25,7 +25,7 @@ import EditEventActivityAction, { import { EventActivityType } from "src/graphql/resolvers/"; interface customEventActivityEditInput extends EventActivityEditInput { - eventActivityID: string; + id: string; eventID?: string; } @@ -36,7 +36,7 @@ interface EventActivityEditPayload { export const EventActivityEditInputType = new GraphQLInputObjectType({ name: "EventActivityEditInput", fields: (): GraphQLInputFieldConfigMap => ({ - eventActivityID: { + id: { description: "id of EventActivity", type: new GraphQLNonNull(GraphQLID), }, @@ -96,7 +96,7 @@ export const EventActivityEditType: GraphQLFieldConfig< ): Promise => { const eventActivity = await EditEventActivityAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.eventActivityID), + mustDecodeIDFromGQLID(input.id), { name: input.name, eventID: mustDecodeNullableIDFromGQLID(input.eventID), diff --git a/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_remove_invite_type.ts b/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_remove_invite_type.ts index 24e8bf925..ffe14672b 100644 --- a/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_remove_invite_type.ts +++ b/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_remove_invite_type.ts @@ -17,7 +17,7 @@ import EventActivityRemoveInviteAction from "src/ent/event_activity/actions/even import { EventActivityType } from "src/graphql/resolvers/"; interface customEventActivityRemoveInviteInput { - eventActivityID: string; + id: string; inviteID: string; } @@ -28,7 +28,7 @@ interface EventActivityRemoveInvitePayload { export const EventActivityRemoveInviteInputType = new GraphQLInputObjectType({ name: "EventActivityRemoveInviteInput", fields: (): GraphQLInputFieldConfigMap => ({ - eventActivityID: { + id: { description: "id of EventActivity", type: new GraphQLNonNull(GraphQLID), }, @@ -70,7 +70,7 @@ export const EventActivityRemoveInviteType: GraphQLFieldConfig< ): Promise => { const eventActivity = await EventActivityRemoveInviteAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.eventActivityID), + mustDecodeIDFromGQLID(input.id), mustDecodeIDFromGQLID(input.inviteID), ); return { eventActivity: eventActivity }; diff --git a/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_rsvp_status_edit_type.ts b/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_rsvp_status_edit_type.ts index 097d156b3..0f012f916 100644 --- a/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_rsvp_status_edit_type.ts +++ b/examples/ent-rsvp/backend/src/graphql/generated/mutations/event_activity/event_activity_rsvp_status_edit_type.ts @@ -22,7 +22,7 @@ import { EventActivityType } from "src/graphql/resolvers/"; interface customEventActivityRsvpStatusEditInput extends EditEventActivityRsvpStatusInput { - eventActivityID: string; + id: string; guestID: string; } @@ -45,7 +45,7 @@ export const EventActivityRsvpStatusInputType = new GraphQLEnumType({ export const EventActivityRsvpStatusEditInputType = new GraphQLInputObjectType({ name: "EventActivityRsvpStatusEditInput", fields: (): GraphQLInputFieldConfigMap => ({ - eventActivityID: { + id: { description: "id of EventActivity", type: new GraphQLNonNull(GraphQLID), }, @@ -93,7 +93,7 @@ export const EventActivityRsvpStatusEditType: GraphQLFieldConfig< ): Promise => { const eventActivity = await EditEventActivityRsvpStatusAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.eventActivityID), + mustDecodeIDFromGQLID(input.id), { rsvpStatus: input.rsvpStatus, guestID: mustDecodeIDFromGQLID(input.guestID), diff --git a/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest/guest_delete_type.ts b/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest/guest_delete_type.ts index 132dddea9..9dbe59cdf 100644 --- a/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest/guest_delete_type.ts +++ b/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest/guest_delete_type.ts @@ -15,7 +15,7 @@ import { mustDecodeIDFromGQLID } from "@snowtop/ent/graphql"; import DeleteGuestAction from "src/ent/guest/actions/delete_guest_action"; interface customGuestDeleteInput { - guestID: string; + id: string; } interface GuestDeletePayload { @@ -25,7 +25,7 @@ interface GuestDeletePayload { export const GuestDeleteInputType = new GraphQLInputObjectType({ name: "GuestDeleteInput", fields: (): GraphQLInputFieldConfigMap => ({ - guestID: { + id: { description: "id of Guest", type: new GraphQLNonNull(GraphQLID), }, @@ -61,8 +61,8 @@ export const GuestDeleteType: GraphQLFieldConfig< ): Promise => { await DeleteGuestAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.guestID), + mustDecodeIDFromGQLID(input.id), ); - return { deletedGuestID: input.guestID }; + return { deletedGuestID: input.id }; }, }; diff --git a/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest/guest_edit_type.ts b/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest/guest_edit_type.ts index f48eb49e1..f060f4d88 100644 --- a/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest/guest_edit_type.ts +++ b/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest/guest_edit_type.ts @@ -20,7 +20,7 @@ import EditGuestAction, { import { GuestType } from "src/graphql/resolvers/"; interface customGuestEditInput extends GuestEditInput { - guestID: string; + id: string; } interface GuestEditPayload { @@ -30,7 +30,7 @@ interface GuestEditPayload { export const GuestEditInputType = new GraphQLInputObjectType({ name: "GuestEditInput", fields: (): GraphQLInputFieldConfigMap => ({ - guestID: { + id: { description: "id of Guest", type: new GraphQLNonNull(GraphQLID), }, @@ -72,7 +72,7 @@ export const GuestEditType: GraphQLFieldConfig< ): Promise => { const guest = await EditGuestAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.guestID), + mustDecodeIDFromGQLID(input.id), { name: input.name, emailAddress: input.emailAddress, diff --git a/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest_group/guest_group_delete_type.ts b/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest_group/guest_group_delete_type.ts index 17eb43d6c..b634600cc 100644 --- a/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest_group/guest_group_delete_type.ts +++ b/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest_group/guest_group_delete_type.ts @@ -15,7 +15,7 @@ import { mustDecodeIDFromGQLID } from "@snowtop/ent/graphql"; import DeleteGuestGroupAction from "src/ent/guest_group/actions/delete_guest_group_action"; interface customGuestGroupDeleteInput { - guestGroupID: string; + id: string; } interface GuestGroupDeletePayload { @@ -25,7 +25,7 @@ interface GuestGroupDeletePayload { export const GuestGroupDeleteInputType = new GraphQLInputObjectType({ name: "GuestGroupDeleteInput", fields: (): GraphQLInputFieldConfigMap => ({ - guestGroupID: { + id: { description: "id of GuestGroup", type: new GraphQLNonNull(GraphQLID), }, @@ -64,8 +64,8 @@ export const GuestGroupDeleteType: GraphQLFieldConfig< ): Promise => { await DeleteGuestGroupAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.guestGroupID), + mustDecodeIDFromGQLID(input.id), ); - return { deletedGuestGroupID: input.guestGroupID }; + return { deletedGuestGroupID: input.id }; }, }; diff --git a/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest_group/guest_group_edit_type.ts b/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest_group/guest_group_edit_type.ts index 6d8a3dbbc..0b29a520d 100644 --- a/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest_group/guest_group_edit_type.ts +++ b/examples/ent-rsvp/backend/src/graphql/generated/mutations/guest_group/guest_group_edit_type.ts @@ -20,7 +20,7 @@ import EditGuestGroupAction, { import { GuestGroupType } from "src/graphql/resolvers/"; interface customGuestGroupEditInput extends GuestGroupEditInput { - guestGroupID: string; + id: string; } interface GuestGroupEditPayload { @@ -30,7 +30,7 @@ interface GuestGroupEditPayload { export const GuestGroupEditInputType = new GraphQLInputObjectType({ name: "GuestGroupEditInput", fields: (): GraphQLInputFieldConfigMap => ({ - guestGroupID: { + id: { description: "id of GuestGroup", type: new GraphQLNonNull(GraphQLID), }, @@ -69,7 +69,7 @@ export const GuestGroupEditType: GraphQLFieldConfig< ): Promise => { const guestGroup = await EditGuestGroupAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.guestGroupID), + mustDecodeIDFromGQLID(input.id), { invitationName: input.invitationName, }, diff --git a/examples/ent-rsvp/backend/src/graphql/generated/schema.gql b/examples/ent-rsvp/backend/src/graphql/generated/schema.gql index 2abf1e2b3..1b8592afd 100644 --- a/examples/ent-rsvp/backend/src/graphql/generated/schema.gql +++ b/examples/ent-rsvp/backend/src/graphql/generated/schema.gql @@ -46,8 +46,8 @@ type EventActivity implements Node { event: Event id: ID! name: String! - startTime: Date! - endTime: Date + startTime: Time! + endTime: Time location: String! description: String inviteAllGuests: Boolean! @@ -256,8 +256,8 @@ type AuthUserPayload { input ActivityEventCreateInput { name: String! - startTime: Date! - endTime: Date + startTime: Time! + endTime: Time location: String! description: String inviteAllGuests: Boolean! @@ -280,7 +280,7 @@ type AddressCreatePayload { input AddressDeleteInput { """id of Address""" - addressID: ID! + id: ID! } type AddressDeletePayload { @@ -289,7 +289,7 @@ type AddressDeletePayload { input AddressEditInput { """id of Address""" - addressID: ID! + id: ID! street: String city: String state: String @@ -313,7 +313,7 @@ input AddressEventActivityCreateInput { input EventActivityAddInviteInput { """id of EventActivity""" - eventActivityID: ID! + id: ID! inviteID: ID! } @@ -324,8 +324,8 @@ type EventActivityAddInvitePayload { input EventActivityCreateInput { name: String! eventID: ID! - startTime: Date! - endTime: Date + startTime: Time! + endTime: Time location: String! description: String inviteAllGuests: Boolean @@ -338,7 +338,7 @@ type EventActivityCreatePayload { input EventActivityDeleteInput { """id of EventActivity""" - eventActivityID: ID! + id: ID! } type EventActivityDeletePayload { @@ -347,11 +347,11 @@ type EventActivityDeletePayload { input EventActivityEditInput { """id of EventActivity""" - eventActivityID: ID! + id: ID! name: String eventID: ID - startTime: Date - endTime: Date + startTime: Time + endTime: Time location: String description: String inviteAllGuests: Boolean @@ -363,7 +363,7 @@ type EventActivityEditPayload { input EventActivityRemoveInviteInput { """id of EventActivity""" - eventActivityID: ID! + id: ID! inviteID: ID! } @@ -373,7 +373,7 @@ type EventActivityRemoveInvitePayload { input EventActivityRsvpStatusEditInput { """id of EventActivity""" - eventActivityID: ID! + id: ID! rsvpStatus: EventActivityRsvpStatusInput! guestID: ID! dietaryRestrictions: String @@ -412,7 +412,7 @@ type GuestCreatePayload { input GuestDeleteInput { """id of Guest""" - guestID: ID! + id: ID! } type GuestDeletePayload { @@ -421,7 +421,7 @@ type GuestDeletePayload { input GuestEditInput { """id of Guest""" - guestID: ID! + id: ID! name: String emailAddress: String } @@ -442,7 +442,7 @@ type GuestGroupCreatePayload { input GuestGroupDeleteInput { """id of GuestGroup""" - guestGroupID: ID! + id: ID! } type GuestGroupDeletePayload { @@ -451,7 +451,7 @@ type GuestGroupDeletePayload { input GuestGroupEditInput { """id of GuestGroup""" - guestGroupID: ID! + id: ID! invitationName: String } @@ -508,6 +508,9 @@ type Mutation { userCreate(input: UserCreateInput!): UserCreatePayload! } +"""Time scalar type""" +scalar Time + """The `Upload` scalar type represents a file upload.""" scalar Upload diff --git a/examples/ent-rsvp/backend/src/graphql/tests/event_activity_type.test.ts b/examples/ent-rsvp/backend/src/graphql/tests/event_activity_type.test.ts index 0c3bf80fd..e5fc7e2e0 100644 --- a/examples/ent-rsvp/backend/src/graphql/tests/event_activity_type.test.ts +++ b/examples/ent-rsvp/backend/src/graphql/tests/event_activity_type.test.ts @@ -57,7 +57,7 @@ test("rsvp", async () => { mutation: "eventActivityRsvpStatusEdit", schema, args: { - eventActivityID: encodeGQLID(activity), + id: encodeGQLID(activity), rsvpStatus: "ATTENDING", guestID: encodeGQLID(guest), }, @@ -84,7 +84,7 @@ test("rsvp", async () => { mutation: "eventActivityRsvpStatusEdit", schema, args: { - eventActivityID: encodeGQLID(activity), + id: encodeGQLID(activity), rsvpStatus: "DECLINED", guestID: encodeGQLID(guest), }, @@ -103,7 +103,7 @@ test("rsvp with dietary restrictions", async () => { mutation: "eventActivityRsvpStatusEdit", schema, args: { - eventActivityID: encodeGQLID(activity), + id: encodeGQLID(activity), rsvpStatus: "ATTENDING", guestID: encodeGQLID(guest), dietaryRestrictions: "shellfish", diff --git a/examples/simple/src/graphql/generated/mutations/contact/contact_delete_type.ts b/examples/simple/src/graphql/generated/mutations/contact/contact_delete_type.ts index df5bb4932..72d12472e 100644 --- a/examples/simple/src/graphql/generated/mutations/contact/contact_delete_type.ts +++ b/examples/simple/src/graphql/generated/mutations/contact/contact_delete_type.ts @@ -19,7 +19,7 @@ import DeleteContactAction from "../../../../ent/contact/actions/delete_contact_ import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customContactDeleteInput { - contactID: string; + id: string; } interface ContactDeletePayload { @@ -29,7 +29,7 @@ interface ContactDeletePayload { export const ContactDeleteInputType = new GraphQLInputObjectType({ name: "ContactDeleteInput", fields: (): GraphQLInputFieldConfigMap => ({ - contactID: { + id: { description: "id of Contact", type: new GraphQLNonNull(GraphQLID), }, @@ -65,8 +65,8 @@ export const ContactDeleteType: GraphQLFieldConfig< ): Promise => { await DeleteContactAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.contactID), + mustDecodeIDFromGQLID(input.id), ); - return { deletedContactID: input.contactID }; + return { deletedContactID: input.id }; }, }; diff --git a/examples/simple/src/graphql/generated/mutations/contact/contact_edit_type.ts b/examples/simple/src/graphql/generated/mutations/contact/contact_edit_type.ts index af4fedf09..30daf619f 100644 --- a/examples/simple/src/graphql/generated/mutations/contact/contact_edit_type.ts +++ b/examples/simple/src/graphql/generated/mutations/contact/contact_edit_type.ts @@ -28,7 +28,7 @@ import { ContactType } from "../../../resolvers"; import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customContactEditInput extends ContactEditInput { - contactID: string; + id: string; userID?: string; } @@ -39,7 +39,7 @@ interface ContactEditPayload { export const ContactEditInputType = new GraphQLInputObjectType({ name: "ContactEditInput", fields: (): GraphQLInputFieldConfigMap => ({ - contactID: { + id: { description: "id of Contact", type: new GraphQLNonNull(GraphQLID), }, @@ -90,7 +90,7 @@ export const ContactEditType: GraphQLFieldConfig< ): Promise => { const contact = await EditContactAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.contactID), + mustDecodeIDFromGQLID(input.id), { emailIds: input.emailIds, phoneNumberIds: input.phoneNumberIds, diff --git a/examples/simple/src/graphql/generated/mutations/contact_email/contact_email_delete_type.ts b/examples/simple/src/graphql/generated/mutations/contact_email/contact_email_delete_type.ts index a90807b0b..197ee44a0 100644 --- a/examples/simple/src/graphql/generated/mutations/contact_email/contact_email_delete_type.ts +++ b/examples/simple/src/graphql/generated/mutations/contact_email/contact_email_delete_type.ts @@ -19,7 +19,7 @@ import DeleteContactEmailAction from "../../../../ent/contact_email/actions/dele import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customContactEmailDeleteInput { - contactEmailID: string; + id: string; } interface ContactEmailDeletePayload { @@ -29,7 +29,7 @@ interface ContactEmailDeletePayload { export const ContactEmailDeleteInputType = new GraphQLInputObjectType({ name: "ContactEmailDeleteInput", fields: (): GraphQLInputFieldConfigMap => ({ - contactEmailID: { + id: { description: "id of ContactEmail", type: new GraphQLNonNull(GraphQLID), }, @@ -68,8 +68,8 @@ export const ContactEmailDeleteType: GraphQLFieldConfig< ): Promise => { await DeleteContactEmailAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.contactEmailID), + mustDecodeIDFromGQLID(input.id), ); - return { deletedContactEmailID: input.contactEmailID }; + return { deletedContactEmailID: input.id }; }, }; diff --git a/examples/simple/src/graphql/generated/mutations/contact_email/contact_email_edit_type.ts b/examples/simple/src/graphql/generated/mutations/contact_email/contact_email_edit_type.ts index 2c305529c..eee7a0e9e 100644 --- a/examples/simple/src/graphql/generated/mutations/contact_email/contact_email_edit_type.ts +++ b/examples/simple/src/graphql/generated/mutations/contact_email/contact_email_edit_type.ts @@ -27,7 +27,7 @@ import { ContactEmailType } from "../../../resolvers"; import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customContactEmailEditInput extends ContactEmailEditInput { - contactEmailID: string; + id: string; contactID?: string; } @@ -38,7 +38,7 @@ interface ContactEmailEditPayload { export const ContactEmailEditInputType = new GraphQLInputObjectType({ name: "ContactEmailEditInput", fields: (): GraphQLInputFieldConfigMap => ({ - contactEmailID: { + id: { description: "id of ContactEmail", type: new GraphQLNonNull(GraphQLID), }, @@ -86,7 +86,7 @@ export const ContactEmailEditType: GraphQLFieldConfig< ): Promise => { const contactEmail = await EditContactEmailAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.contactEmailID), + mustDecodeIDFromGQLID(input.id), { emailAddress: input.emailAddress, label: input.label, diff --git a/examples/simple/src/graphql/generated/mutations/contact_phone_number/contact_phone_number_delete_type.ts b/examples/simple/src/graphql/generated/mutations/contact_phone_number/contact_phone_number_delete_type.ts index 9ce8ca1ab..337d88a1b 100644 --- a/examples/simple/src/graphql/generated/mutations/contact_phone_number/contact_phone_number_delete_type.ts +++ b/examples/simple/src/graphql/generated/mutations/contact_phone_number/contact_phone_number_delete_type.ts @@ -19,7 +19,7 @@ import DeleteContactPhoneNumberAction from "../../../../ent/contact_phone_number import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customContactPhoneNumberDeleteInput { - contactPhoneNumberID: string; + id: string; } interface ContactPhoneNumberDeletePayload { @@ -29,7 +29,7 @@ interface ContactPhoneNumberDeletePayload { export const ContactPhoneNumberDeleteInputType = new GraphQLInputObjectType({ name: "ContactPhoneNumberDeleteInput", fields: (): GraphQLInputFieldConfigMap => ({ - contactPhoneNumberID: { + id: { description: "id of ContactPhoneNumber", type: new GraphQLNonNull(GraphQLID), }, @@ -68,8 +68,8 @@ export const ContactPhoneNumberDeleteType: GraphQLFieldConfig< ): Promise => { await DeleteContactPhoneNumberAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.contactPhoneNumberID), + mustDecodeIDFromGQLID(input.id), ); - return { deletedContactPhoneNumberID: input.contactPhoneNumberID }; + return { deletedContactPhoneNumberID: input.id }; }, }; diff --git a/examples/simple/src/graphql/generated/mutations/contact_phone_number/contact_phone_number_edit_type.ts b/examples/simple/src/graphql/generated/mutations/contact_phone_number/contact_phone_number_edit_type.ts index 293c5bac3..24a979de6 100644 --- a/examples/simple/src/graphql/generated/mutations/contact_phone_number/contact_phone_number_edit_type.ts +++ b/examples/simple/src/graphql/generated/mutations/contact_phone_number/contact_phone_number_edit_type.ts @@ -28,7 +28,7 @@ import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customContactPhoneNumberEditInput extends ContactPhoneNumberEditInput { - contactPhoneNumberID: string; + id: string; contactID?: string; } @@ -39,7 +39,7 @@ interface ContactPhoneNumberEditPayload { export const ContactPhoneNumberEditInputType = new GraphQLInputObjectType({ name: "ContactPhoneNumberEditInput", fields: (): GraphQLInputFieldConfigMap => ({ - contactPhoneNumberID: { + id: { description: "id of ContactPhoneNumber", type: new GraphQLNonNull(GraphQLID), }, @@ -87,7 +87,7 @@ export const ContactPhoneNumberEditType: GraphQLFieldConfig< ): Promise => { const contactPhoneNumber = await EditContactPhoneNumberAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.contactPhoneNumberID), + mustDecodeIDFromGQLID(input.id), { phoneNumber: input.phoneNumber, label: input.label, diff --git a/examples/simple/src/graphql/generated/mutations/event/event_add_host_type.ts b/examples/simple/src/graphql/generated/mutations/event/event_add_host_type.ts index d6f599467..94682245f 100644 --- a/examples/simple/src/graphql/generated/mutations/event/event_add_host_type.ts +++ b/examples/simple/src/graphql/generated/mutations/event/event_add_host_type.ts @@ -21,7 +21,7 @@ import { EventType } from "../../../resolvers"; import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customEventAddHostInput { - eventID: string; + id: string; hostID: string; } @@ -32,7 +32,7 @@ interface EventAddHostPayload { export const EventAddHostInputType = new GraphQLInputObjectType({ name: "EventAddHostInput", fields: (): GraphQLInputFieldConfigMap => ({ - eventID: { + id: { description: "id of Event", type: new GraphQLNonNull(GraphQLID), }, @@ -71,7 +71,7 @@ export const EventAddHostType: GraphQLFieldConfig< ): Promise => { const event = await EventAddHostAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.eventID), + mustDecodeIDFromGQLID(input.id), mustDecodeIDFromGQLID(input.hostID), ); return { event: event }; diff --git a/examples/simple/src/graphql/generated/mutations/event/event_delete_type.ts b/examples/simple/src/graphql/generated/mutations/event/event_delete_type.ts index b8e3eb02d..13142e1ed 100644 --- a/examples/simple/src/graphql/generated/mutations/event/event_delete_type.ts +++ b/examples/simple/src/graphql/generated/mutations/event/event_delete_type.ts @@ -19,7 +19,7 @@ import DeleteEventAction from "../../../../ent/event/actions/delete_event_action import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customEventDeleteInput { - eventID: string; + id: string; } interface EventDeletePayload { @@ -29,7 +29,7 @@ interface EventDeletePayload { export const EventDeleteInputType = new GraphQLInputObjectType({ name: "EventDeleteInput", fields: (): GraphQLInputFieldConfigMap => ({ - eventID: { + id: { description: "id of Event", type: new GraphQLNonNull(GraphQLID), }, @@ -65,8 +65,8 @@ export const EventDeleteType: GraphQLFieldConfig< ): Promise => { await DeleteEventAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.eventID), + mustDecodeIDFromGQLID(input.id), ); - return { deletedEventID: input.eventID }; + return { deletedEventID: input.id }; }, }; diff --git a/examples/simple/src/graphql/generated/mutations/event/event_edit_type.ts b/examples/simple/src/graphql/generated/mutations/event/event_edit_type.ts index b316b7d3f..2cb4076cb 100644 --- a/examples/simple/src/graphql/generated/mutations/event/event_edit_type.ts +++ b/examples/simple/src/graphql/generated/mutations/event/event_edit_type.ts @@ -28,7 +28,7 @@ import { EventType } from "../../../resolvers"; import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customEventEditInput extends Omit { - eventID: string; + id: string; creatorID?: string; eventLocation?: string; addressID?: string; @@ -41,7 +41,7 @@ interface EventEditPayload { export const EventEditInputType = new GraphQLInputObjectType({ name: "EventEditInput", fields: (): GraphQLInputFieldConfigMap => ({ - eventID: { + id: { description: "id of Event", type: new GraphQLNonNull(GraphQLID), }, @@ -95,7 +95,7 @@ export const EventEditType: GraphQLFieldConfig< ): Promise => { const event = await EditEventAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.eventID), + mustDecodeIDFromGQLID(input.id), { name: input.name, creatorID: mustDecodeNullableIDFromGQLID(input.creatorID), diff --git a/examples/simple/src/graphql/generated/mutations/event/event_remove_host_type.ts b/examples/simple/src/graphql/generated/mutations/event/event_remove_host_type.ts index 958a0888d..7896c43bc 100644 --- a/examples/simple/src/graphql/generated/mutations/event/event_remove_host_type.ts +++ b/examples/simple/src/graphql/generated/mutations/event/event_remove_host_type.ts @@ -21,7 +21,7 @@ import { EventType } from "../../../resolvers"; import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customEventRemoveHostInput { - eventID: string; + id: string; hostID: string; } @@ -32,7 +32,7 @@ interface EventRemoveHostPayload { export const EventRemoveHostInputType = new GraphQLInputObjectType({ name: "EventRemoveHostInput", fields: (): GraphQLInputFieldConfigMap => ({ - eventID: { + id: { description: "id of Event", type: new GraphQLNonNull(GraphQLID), }, @@ -74,7 +74,7 @@ export const EventRemoveHostType: GraphQLFieldConfig< ): Promise => { const event = await EventRemoveHostAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.eventID), + mustDecodeIDFromGQLID(input.id), mustDecodeIDFromGQLID(input.hostID), ); return { event: event }; diff --git a/examples/simple/src/graphql/generated/mutations/event/event_rsvp_status_edit_type.ts b/examples/simple/src/graphql/generated/mutations/event/event_rsvp_status_edit_type.ts index 864447b1c..576ca4280 100644 --- a/examples/simple/src/graphql/generated/mutations/event/event_rsvp_status_edit_type.ts +++ b/examples/simple/src/graphql/generated/mutations/event/event_rsvp_status_edit_type.ts @@ -24,7 +24,7 @@ import { EventType } from "../../../resolvers"; import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customEventRsvpStatusEditInput extends EditEventRsvpStatusInput { - eventID: string; + id: string; userID: string; } @@ -50,7 +50,7 @@ export const EventRsvpStatusInputType = new GraphQLEnumType({ export const EventRsvpStatusEditInputType = new GraphQLInputObjectType({ name: "EventRsvpStatusEditInput", fields: (): GraphQLInputFieldConfigMap => ({ - eventID: { + id: { description: "id of Event", type: new GraphQLNonNull(GraphQLID), }, @@ -95,7 +95,7 @@ export const EventRsvpStatusEditType: GraphQLFieldConfig< ): Promise => { const event = await EditEventRsvpStatusAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.eventID), + mustDecodeIDFromGQLID(input.id), { rsvpStatus: input.rsvpStatus, userID: mustDecodeIDFromGQLID(input.userID), diff --git a/examples/simple/src/graphql/generated/mutations/user/confirm_email_address_edit_type.ts b/examples/simple/src/graphql/generated/mutations/user/confirm_email_address_edit_type.ts index 6f6af4fd3..737ad873b 100644 --- a/examples/simple/src/graphql/generated/mutations/user/confirm_email_address_edit_type.ts +++ b/examples/simple/src/graphql/generated/mutations/user/confirm_email_address_edit_type.ts @@ -25,7 +25,7 @@ import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customConfirmEditEmailAddressInput extends ConfirmEditEmailAddressInput { - userID: string; + id: string; } interface ConfirmEditEmailAddressPayload { @@ -35,7 +35,7 @@ interface ConfirmEditEmailAddressPayload { export const ConfirmEditEmailAddressInputType = new GraphQLInputObjectType({ name: "ConfirmEditEmailAddressInput", fields: (): GraphQLInputFieldConfigMap => ({ - userID: { + id: { description: "id of User", type: new GraphQLNonNull(GraphQLID), }, @@ -80,7 +80,7 @@ export const ConfirmEmailAddressEditType: GraphQLFieldConfig< ): Promise => { const user = await ConfirmEditEmailAddressAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.userID), + mustDecodeIDFromGQLID(input.id), { emailAddress: input.emailAddress, code: input.code, diff --git a/examples/simple/src/graphql/generated/mutations/user/confirm_phone_number_edit_type.ts b/examples/simple/src/graphql/generated/mutations/user/confirm_phone_number_edit_type.ts index f1a57251a..19655667c 100644 --- a/examples/simple/src/graphql/generated/mutations/user/confirm_phone_number_edit_type.ts +++ b/examples/simple/src/graphql/generated/mutations/user/confirm_phone_number_edit_type.ts @@ -25,7 +25,7 @@ import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customConfirmEditPhoneNumberInput extends ConfirmEditPhoneNumberInput { - userID: string; + id: string; } interface ConfirmEditPhoneNumberPayload { @@ -35,7 +35,7 @@ interface ConfirmEditPhoneNumberPayload { export const ConfirmEditPhoneNumberInputType = new GraphQLInputObjectType({ name: "ConfirmEditPhoneNumberInput", fields: (): GraphQLInputFieldConfigMap => ({ - userID: { + id: { description: "id of User", type: new GraphQLNonNull(GraphQLID), }, @@ -80,7 +80,7 @@ export const ConfirmPhoneNumberEditType: GraphQLFieldConfig< ): Promise => { const user = await ConfirmEditPhoneNumberAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.userID), + mustDecodeIDFromGQLID(input.id), { phoneNumber: input.phoneNumber, code: input.code, diff --git a/examples/simple/src/graphql/generated/mutations/user/email_address_edit_type.ts b/examples/simple/src/graphql/generated/mutations/user/email_address_edit_type.ts index 895acd712..f33d60fbd 100644 --- a/examples/simple/src/graphql/generated/mutations/user/email_address_edit_type.ts +++ b/examples/simple/src/graphql/generated/mutations/user/email_address_edit_type.ts @@ -24,7 +24,7 @@ import { UserType } from "../../../resolvers"; import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customEditEmailAddressInput extends EditEmailAddressInput { - userID: string; + id: string; } interface EditEmailAddressPayload { @@ -34,7 +34,7 @@ interface EditEmailAddressPayload { export const EditEmailAddressInputType = new GraphQLInputObjectType({ name: "EditEmailAddressInput", fields: (): GraphQLInputFieldConfigMap => ({ - userID: { + id: { description: "id of User", type: new GraphQLNonNull(GraphQLID), }, @@ -76,7 +76,7 @@ export const EmailAddressEditType: GraphQLFieldConfig< ): Promise => { const user = await EditEmailAddressAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.userID), + mustDecodeIDFromGQLID(input.id), { newEmail: input.newEmail, }, diff --git a/examples/simple/src/graphql/generated/mutations/user/phone_number_edit_type.ts b/examples/simple/src/graphql/generated/mutations/user/phone_number_edit_type.ts index f6c958f36..5f46254e3 100644 --- a/examples/simple/src/graphql/generated/mutations/user/phone_number_edit_type.ts +++ b/examples/simple/src/graphql/generated/mutations/user/phone_number_edit_type.ts @@ -24,7 +24,7 @@ import { UserType } from "../../../resolvers"; import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customEditPhoneNumberInput extends EditPhoneNumberInput { - userID: string; + id: string; } interface EditPhoneNumberPayload { @@ -34,7 +34,7 @@ interface EditPhoneNumberPayload { export const EditPhoneNumberInputType = new GraphQLInputObjectType({ name: "EditPhoneNumberInput", fields: (): GraphQLInputFieldConfigMap => ({ - userID: { + id: { description: "id of User", type: new GraphQLNonNull(GraphQLID), }, @@ -76,7 +76,7 @@ export const PhoneNumberEditType: GraphQLFieldConfig< ): Promise => { const user = await EditPhoneNumberAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.userID), + mustDecodeIDFromGQLID(input.id), { newPhoneNumber: input.newPhoneNumber, }, diff --git a/examples/simple/src/graphql/generated/mutations/user/user_delete_2_type.ts b/examples/simple/src/graphql/generated/mutations/user/user_delete_2_type.ts index 376a35272..be525cb1b 100644 --- a/examples/simple/src/graphql/generated/mutations/user/user_delete_2_type.ts +++ b/examples/simple/src/graphql/generated/mutations/user/user_delete_2_type.ts @@ -22,7 +22,7 @@ import DeleteUserAction2, { import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customDeleteUserInput2 extends DeleteUserInput2 { - userID: string; + id: string; } interface DeleteUserInput2Payload { @@ -32,7 +32,7 @@ interface DeleteUserInput2Payload { export const DeleteUserInput2Type = new GraphQLInputObjectType({ name: "DeleteUserInput2", fields: (): GraphQLInputFieldConfigMap => ({ - userID: { + id: { description: "id of User", type: new GraphQLNonNull(GraphQLID), }, @@ -74,11 +74,11 @@ export const UserDelete2Type: GraphQLFieldConfig< ): Promise => { await DeleteUserAction2.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.userID), + mustDecodeIDFromGQLID(input.id), { log: input.log, }, ); - return { deletedUserID: input.userID }; + return { deletedUserID: input.id }; }, }; diff --git a/examples/simple/src/graphql/generated/mutations/user/user_delete_type.ts b/examples/simple/src/graphql/generated/mutations/user/user_delete_type.ts index 1bf677b1f..b27c68a65 100644 --- a/examples/simple/src/graphql/generated/mutations/user/user_delete_type.ts +++ b/examples/simple/src/graphql/generated/mutations/user/user_delete_type.ts @@ -19,7 +19,7 @@ import DeleteUserAction from "../../../../ent/user/actions/delete_user_action"; import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customUserDeleteInput { - userID: string; + id: string; } interface UserDeletePayload { @@ -29,7 +29,7 @@ interface UserDeletePayload { export const UserDeleteInputType = new GraphQLInputObjectType({ name: "UserDeleteInput", fields: (): GraphQLInputFieldConfigMap => ({ - userID: { + id: { description: "id of User", type: new GraphQLNonNull(GraphQLID), }, @@ -65,8 +65,8 @@ export const UserDeleteType: GraphQLFieldConfig< ): Promise => { await DeleteUserAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.userID), + mustDecodeIDFromGQLID(input.id), ); - return { deletedUserID: input.userID }; + return { deletedUserID: input.id }; }, }; diff --git a/examples/simple/src/graphql/generated/mutations/user/user_edit_type.ts b/examples/simple/src/graphql/generated/mutations/user/user_edit_type.ts index ba1b67272..85182096a 100644 --- a/examples/simple/src/graphql/generated/mutations/user/user_edit_type.ts +++ b/examples/simple/src/graphql/generated/mutations/user/user_edit_type.ts @@ -24,7 +24,7 @@ import { UserType } from "../../../resolvers"; import { ExampleViewer as ExampleViewerAlias } from "../../../../viewer/viewer"; interface customUserEditInput extends UserEditInput { - userID: string; + id: string; } interface UserEditPayload { @@ -34,7 +34,7 @@ interface UserEditPayload { export const UserEditInputType = new GraphQLInputObjectType({ name: "UserEditInput", fields: (): GraphQLInputFieldConfigMap => ({ - userID: { + id: { description: "id of User", type: new GraphQLNonNull(GraphQLID), }, @@ -76,7 +76,7 @@ export const UserEditType: GraphQLFieldConfig< ): Promise => { const user = await EditUserAction.saveXFromID( context.getViewer(), - mustDecodeIDFromGQLID(input.userID), + mustDecodeIDFromGQLID(input.id), { firstName: input.firstName, lastName: input.lastName, diff --git a/examples/simple/src/graphql/generated/schema.gql b/examples/simple/src/graphql/generated/schema.gql index 2756657da..f51ef03f0 100644 --- a/examples/simple/src/graphql/generated/schema.gql +++ b/examples/simple/src/graphql/generated/schema.gql @@ -655,7 +655,7 @@ type CommentCreatePayload { input ConfirmEditEmailAddressInput { """id of User""" - userID: ID! + id: ID! emailAddress: String! code: String! } @@ -666,7 +666,7 @@ type ConfirmEditEmailAddressPayload { input ConfirmEditPhoneNumberInput { """id of User""" - userID: ID! + id: ID! phoneNumber: String! code: String! } @@ -689,7 +689,7 @@ type ContactCreatePayload { input ContactDeleteInput { """id of Contact""" - contactID: ID! + id: ID! } type ContactDeletePayload { @@ -698,7 +698,7 @@ type ContactDeletePayload { input ContactEditInput { """id of Contact""" - contactID: ID! + id: ID! emailIds: [ID!] phoneNumberIds: [ID!] firstName: String @@ -722,7 +722,7 @@ type ContactEmailCreatePayload { input ContactEmailDeleteInput { """id of ContactEmail""" - contactEmailID: ID! + id: ID! } type ContactEmailDeletePayload { @@ -731,7 +731,7 @@ type ContactEmailDeletePayload { input ContactEmailEditInput { """id of ContactEmail""" - contactEmailID: ID! + id: ID! emailAddress: String label: String contactID: ID @@ -753,7 +753,7 @@ type ContactPhoneNumberCreatePayload { input ContactPhoneNumberDeleteInput { """id of ContactPhoneNumber""" - contactPhoneNumberID: ID! + id: ID! } type ContactPhoneNumberDeletePayload { @@ -762,7 +762,7 @@ type ContactPhoneNumberDeletePayload { input ContactPhoneNumberEditInput { """id of ContactPhoneNumber""" - contactPhoneNumberID: ID! + id: ID! phoneNumber: String label: String contactID: ID @@ -778,13 +778,13 @@ type DeleteUserInput2Payload { input DeleteUserInput2 { """id of User""" - userID: ID! + id: ID! log: Boolean! } input EditEmailAddressInput { """id of User""" - userID: ID! + id: ID! newEmail: String! } @@ -794,7 +794,7 @@ type EditEmailAddressPayload { input EditPhoneNumberInput { """id of User""" - userID: ID! + id: ID! newPhoneNumber: String! } @@ -809,7 +809,7 @@ input EmailContactCreateInput { input EventAddHostInput { """id of Event""" - eventID: ID! + id: ID! hostID: ID! } @@ -832,7 +832,7 @@ type EventCreatePayload { input EventDeleteInput { """id of Event""" - eventID: ID! + id: ID! } type EventDeletePayload { @@ -841,7 +841,7 @@ type EventDeletePayload { input EventEditInput { """id of Event""" - eventID: ID! + id: ID! name: String creatorID: ID startTime: Time @@ -856,7 +856,7 @@ type EventEditPayload { input EventRemoveHostInput { """id of Event""" - eventID: ID! + id: ID! hostID: ID! } @@ -866,7 +866,7 @@ type EventRemoveHostPayload { input EventRsvpStatusEditInput { """id of Event""" - eventID: ID! + id: ID! rsvpStatus: EventRsvpStatusInput! userID: ID! } @@ -932,7 +932,7 @@ type UserCreatePayload { input UserDeleteInput { """id of User""" - userID: ID! + id: ID! } type UserDeletePayload { @@ -941,7 +941,7 @@ type UserDeletePayload { input UserEditInput { """id of User""" - userID: ID! + id: ID! firstName: String lastName: String } diff --git a/examples/simple/src/graphql/mutations/tests/user_mutations.test.ts b/examples/simple/src/graphql/mutations/tests/user_mutations.test.ts index 0d177a34b..f6f069b4e 100644 --- a/examples/simple/src/graphql/mutations/tests/user_mutations.test.ts +++ b/examples/simple/src/graphql/mutations/tests/user_mutations.test.ts @@ -83,7 +83,7 @@ test("edit", async () => { getConfig( "userEdit", { - userID: encodeGQLID(user), + id: encodeGQLID(user), firstName: "Jon2", }, new ExampleViewer(user.id), @@ -110,7 +110,7 @@ test("edit no permissions, logged out viewer", async () => { getConfig( "userEdit", { - userID: encodeGQLID(user), + id: encodeGQLID(user), firstName: "Jon2", }, loggedOutViewer, @@ -140,7 +140,7 @@ test("edit no permissions, other viewer", async () => { getConfig( "userEdit", { - userID: encodeGQLID(user), + id: encodeGQLID(user), firstName: "Jon2", }, new ExampleViewer(user2.id), @@ -167,7 +167,7 @@ test("delete", async () => { getConfig( "userDelete", { - userID: encodeGQLID(user), + id: encodeGQLID(user), }, new ExampleViewer(user.id), ), @@ -197,7 +197,7 @@ test("delete 2", async () => { getConfig( "userDelete2", { - userID: encodeGQLID(user), + id: encodeGQLID(user), log: true, }, new ExampleViewer(user.id), @@ -231,7 +231,7 @@ test("delete. other user no permissions", async () => { getConfig( "userDelete", { - userID: encodeGQLID(user), + id: encodeGQLID(user), }, new ExampleViewer(user2.id), { diff --git a/examples/simple/src/graphql/tests/event_type.test.ts b/examples/simple/src/graphql/tests/event_type.test.ts index aabfcf477..a14888a26 100644 --- a/examples/simple/src/graphql/tests/event_type.test.ts +++ b/examples/simple/src/graphql/tests/event_type.test.ts @@ -141,7 +141,7 @@ test("event edit", async () => { schema, mutation: "eventEdit", args: { - eventID: encodeGQLID(event), + id: encodeGQLID(event), name: "event2", }, }, @@ -155,7 +155,7 @@ test("event edit", async () => { schema, mutation: "eventEdit", args: { - eventID: encodeGQLID(event), + id: encodeGQLID(event), addressID: encodeGQLID(address), }, }, @@ -170,7 +170,7 @@ test("event edit", async () => { mutation: "eventEdit", nullQueryPaths: ["event.address"], args: { - eventID: encodeGQLID(event), + id: encodeGQLID(event), addressID: null, }, }, @@ -248,7 +248,7 @@ test("event rsvp status edit", async () => { mutation: "eventRsvpStatusEdit", schema, args: { - eventID: encodeGQLID(event), + id: encodeGQLID(event), userID: encodeGQLID(user), rsvpStatus: "MAYBE", }, diff --git a/examples/todo-sqlite/src/graphql/generated/mutations/account/delete_account_type.ts b/examples/todo-sqlite/src/graphql/generated/mutations/account/delete_account_type.ts index bb24751a0..e714914ab 100644 --- a/examples/todo-sqlite/src/graphql/generated/mutations/account/delete_account_type.ts +++ b/examples/todo-sqlite/src/graphql/generated/mutations/account/delete_account_type.ts @@ -14,7 +14,7 @@ import { RequestContext, Viewer } from "@snowtop/ent"; import DeleteAccountAction from "src/ent/account/actions/delete_account_action"; interface customDeleteAccountInput { - account_id: string; + id: string; } interface DeleteAccountPayload { @@ -24,7 +24,7 @@ interface DeleteAccountPayload { export const DeleteAccountInputType = new GraphQLInputObjectType({ name: "DeleteAccountInput", fields: (): GraphQLInputFieldConfigMap => ({ - account_id: { + id: { description: "id of Account", type: new GraphQLNonNull(GraphQLID), }, @@ -58,10 +58,7 @@ export const DeleteAccountType: GraphQLFieldConfig< context: RequestContext, _info: GraphQLResolveInfo, ): Promise => { - await DeleteAccountAction.saveXFromID( - context.getViewer(), - input.account_id, - ); - return { deleted_account_id: input.account_id }; + await DeleteAccountAction.saveXFromID(context.getViewer(), input.id); + return { deleted_account_id: input.id }; }, }; diff --git a/examples/todo-sqlite/src/graphql/generated/mutations/account/edit_account_type.ts b/examples/todo-sqlite/src/graphql/generated/mutations/account/edit_account_type.ts index 8e86dff44..47d3aeb8b 100644 --- a/examples/todo-sqlite/src/graphql/generated/mutations/account/edit_account_type.ts +++ b/examples/todo-sqlite/src/graphql/generated/mutations/account/edit_account_type.ts @@ -20,7 +20,7 @@ import { AccountStateType, AccountType } from "src/graphql/resolvers/"; interface customEditAccountInput extends Omit { - account_id: string; + id: string; phone_number?: string; account_state?: AccountState | null; } @@ -32,7 +32,7 @@ interface EditAccountPayload { export const EditAccountInputType = new GraphQLInputObjectType({ name: "EditAccountInput", fields: (): GraphQLInputFieldConfigMap => ({ - account_id: { + id: { description: "id of Account", type: new GraphQLNonNull(GraphQLID), }, @@ -77,7 +77,7 @@ export const EditAccountType: GraphQLFieldConfig< ): Promise => { const account = await EditAccountAction.saveXFromID( context.getViewer(), - input.account_id, + input.id, { name: input.name, phoneNumber: input.phone_number, diff --git a/examples/todo-sqlite/src/graphql/generated/mutations/todo/add_todo_tag_type.ts b/examples/todo-sqlite/src/graphql/generated/mutations/todo/add_todo_tag_type.ts index 4ac524b2d..a872d6079 100644 --- a/examples/todo-sqlite/src/graphql/generated/mutations/todo/add_todo_tag_type.ts +++ b/examples/todo-sqlite/src/graphql/generated/mutations/todo/add_todo_tag_type.ts @@ -16,7 +16,7 @@ import TodoAddTagAction from "src/ent/todo/actions/todo_add_tag_action"; import { TodoType } from "src/graphql/resolvers/"; interface customAddTodoTagInput { - todo_id: string; + id: string; tag_id: string; } @@ -27,7 +27,7 @@ interface AddTodoTagPayload { export const AddTodoTagInputType = new GraphQLInputObjectType({ name: "AddTodoTagInput", fields: (): GraphQLInputFieldConfigMap => ({ - todo_id: { + id: { description: "id of Todo", type: new GraphQLNonNull(GraphQLID), }, @@ -66,7 +66,7 @@ export const AddTodoTagType: GraphQLFieldConfig< ): Promise => { const todo = await TodoAddTagAction.saveXFromID( context.getViewer(), - input.todo_id, + input.id, input.tag_id, ); return { todo: todo }; diff --git a/examples/todo-sqlite/src/graphql/generated/mutations/todo/change_todo_status_type.ts b/examples/todo-sqlite/src/graphql/generated/mutations/todo/change_todo_status_type.ts index 9f9766499..0b0b03e47 100644 --- a/examples/todo-sqlite/src/graphql/generated/mutations/todo/change_todo_status_type.ts +++ b/examples/todo-sqlite/src/graphql/generated/mutations/todo/change_todo_status_type.ts @@ -19,7 +19,7 @@ import ChangeTodoStatusAction, { import { TodoType } from "src/graphql/resolvers/"; interface customChangeTodoStatusInput extends ChangeTodoStatusInput { - todo_id: string; + id: string; } interface ChangeTodoStatusPayload { @@ -29,7 +29,7 @@ interface ChangeTodoStatusPayload { export const ChangeTodoStatusInputType = new GraphQLInputObjectType({ name: "ChangeTodoStatusInput", fields: (): GraphQLInputFieldConfigMap => ({ - todo_id: { + id: { description: "id of Todo", type: new GraphQLNonNull(GraphQLID), }, @@ -71,7 +71,7 @@ export const ChangeTodoStatusType: GraphQLFieldConfig< ): Promise => { const todo = await ChangeTodoStatusAction.saveXFromID( context.getViewer(), - input.todo_id, + input.id, { completed: input.completed, }, diff --git a/examples/todo-sqlite/src/graphql/generated/mutations/todo/delete_todo_type.ts b/examples/todo-sqlite/src/graphql/generated/mutations/todo/delete_todo_type.ts index 9997d6ed8..cb7014930 100644 --- a/examples/todo-sqlite/src/graphql/generated/mutations/todo/delete_todo_type.ts +++ b/examples/todo-sqlite/src/graphql/generated/mutations/todo/delete_todo_type.ts @@ -14,7 +14,7 @@ import { RequestContext, Viewer } from "@snowtop/ent"; import DeleteTodoAction from "src/ent/todo/actions/delete_todo_action"; interface customDeleteTodoInput { - todo_id: string; + id: string; } interface DeleteTodoPayload { @@ -24,7 +24,7 @@ interface DeleteTodoPayload { export const DeleteTodoInputType = new GraphQLInputObjectType({ name: "DeleteTodoInput", fields: (): GraphQLInputFieldConfigMap => ({ - todo_id: { + id: { description: "id of Todo", type: new GraphQLNonNull(GraphQLID), }, @@ -58,7 +58,7 @@ export const DeleteTodoType: GraphQLFieldConfig< context: RequestContext, _info: GraphQLResolveInfo, ): Promise => { - await DeleteTodoAction.saveXFromID(context.getViewer(), input.todo_id); - return { deleted_todo_id: input.todo_id }; + await DeleteTodoAction.saveXFromID(context.getViewer(), input.id); + return { deleted_todo_id: input.id }; }, }; diff --git a/examples/todo-sqlite/src/graphql/generated/mutations/todo/remove_todo_tag_type.ts b/examples/todo-sqlite/src/graphql/generated/mutations/todo/remove_todo_tag_type.ts index 8294c98d7..41bad3d1b 100644 --- a/examples/todo-sqlite/src/graphql/generated/mutations/todo/remove_todo_tag_type.ts +++ b/examples/todo-sqlite/src/graphql/generated/mutations/todo/remove_todo_tag_type.ts @@ -16,7 +16,7 @@ import TodoRemoveTagAction from "src/ent/todo/actions/todo_remove_tag_action"; import { TodoType } from "src/graphql/resolvers/"; interface customRemoveTodoTagInput { - todo_id: string; + id: string; tag_id: string; } @@ -27,7 +27,7 @@ interface RemoveTodoTagPayload { export const RemoveTodoTagInputType = new GraphQLInputObjectType({ name: "RemoveTodoTagInput", fields: (): GraphQLInputFieldConfigMap => ({ - todo_id: { + id: { description: "id of Todo", type: new GraphQLNonNull(GraphQLID), }, @@ -66,7 +66,7 @@ export const RemoveTodoTagType: GraphQLFieldConfig< ): Promise => { const todo = await TodoRemoveTagAction.saveXFromID( context.getViewer(), - input.todo_id, + input.id, input.tag_id, ); return { todo: todo }; diff --git a/examples/todo-sqlite/src/graphql/generated/mutations/todo/rename_todo_type.ts b/examples/todo-sqlite/src/graphql/generated/mutations/todo/rename_todo_type.ts index c18e7f650..545e6fb24 100644 --- a/examples/todo-sqlite/src/graphql/generated/mutations/todo/rename_todo_type.ts +++ b/examples/todo-sqlite/src/graphql/generated/mutations/todo/rename_todo_type.ts @@ -20,7 +20,7 @@ import { TodoType } from "src/graphql/resolvers/"; interface customRenameTodoInput extends Omit { - todo_id: string; + id: string; reason_for_change?: string | null; } @@ -31,7 +31,7 @@ interface RenameTodoPayload { export const RenameTodoInputType = new GraphQLInputObjectType({ name: "RenameTodoInput", fields: (): GraphQLInputFieldConfigMap => ({ - todo_id: { + id: { description: "id of Todo", type: new GraphQLNonNull(GraphQLID), }, @@ -73,7 +73,7 @@ export const RenameTodoType: GraphQLFieldConfig< ): Promise => { const todo = await RenameTodoStatusAction.saveXFromID( context.getViewer(), - input.todo_id, + input.id, { text: input.text, reasonForChange: input.reason_for_change, diff --git a/examples/todo-sqlite/src/graphql/generated/schema.gql b/examples/todo-sqlite/src/graphql/generated/schema.gql index 0c8dbff96..bf7904c32 100644 --- a/examples/todo-sqlite/src/graphql/generated/schema.gql +++ b/examples/todo-sqlite/src/graphql/generated/schema.gql @@ -134,7 +134,7 @@ type TodoToTagsConnection implements Connection { input AddTodoTagInput { """id of Todo""" - todo_id: ID! + id: ID! tag_id: ID! } @@ -144,7 +144,7 @@ type AddTodoTagPayload { input ChangeTodoStatusInput { """id of Todo""" - todo_id: ID! + id: ID! completed: Boolean } @@ -183,7 +183,7 @@ type CreateTodoPayload { input DeleteAccountInput { """id of Account""" - account_id: ID! + id: ID! } type DeleteAccountPayload { @@ -192,7 +192,7 @@ type DeleteAccountPayload { input DeleteTodoInput { """id of Todo""" - todo_id: ID! + id: ID! } type DeleteTodoPayload { @@ -201,7 +201,7 @@ type DeleteTodoPayload { input EditAccountInput { """id of Account""" - account_id: ID! + id: ID! name: String phone_number: String account_state: AccountState @@ -213,7 +213,7 @@ type EditAccountPayload { input RemoveTodoTagInput { """id of Todo""" - todo_id: ID! + id: ID! tag_id: ID! } @@ -223,7 +223,7 @@ type RemoveTodoTagPayload { input RenameTodoInput { """id of Todo""" - todo_id: ID! + id: ID! text: String reason_for_change: String } diff --git a/examples/todo-sqlite/src/graphql/tests/todo.test.ts b/examples/todo-sqlite/src/graphql/tests/todo.test.ts index 01632c911..36cd4d1a3 100644 --- a/examples/todo-sqlite/src/graphql/tests/todo.test.ts +++ b/examples/todo-sqlite/src/graphql/tests/todo.test.ts @@ -263,7 +263,7 @@ test("edit", async () => { schema: schema, mutation: "renameTodo", args: { - todo_id: todo.id, + id: todo.id, text: "watch GOT tomorrow", reason_for_change: "time for fun", }, @@ -285,7 +285,7 @@ test("delete", async () => { viewer: account.viewer, schema: schema, mutation: "deleteTodo", - args: { todo_id: todo.id }, + args: { id: todo.id }, }, ["deleted_todo_id", todo.id], ); @@ -304,7 +304,7 @@ test("todo tag", async () => { schema, mutation: "addTodoTag", args: { - todo_id: todo.id, + id: todo.id, tag_id: tag.id, }, }, diff --git a/internal/codegen/codegenapi/api.go b/internal/codegen/codegenapi/api.go index 70e857f16..5d99b0b4b 100644 --- a/internal/codegen/codegenapi/api.go +++ b/internal/codegen/codegenapi/api.go @@ -1,6 +1,8 @@ package codegenapi import ( + "strings" + "github.com/iancoleman/strcase" "github.com/lolopinto/ent/internal/codepath" "github.com/lolopinto/ent/internal/tsimport" @@ -117,6 +119,10 @@ func (cfg DummyConfig) GetTemplatizedViewer() *ViewerConfig { var _ Config = &DummyConfig{} func GraphQLName(cfg Config, name string) string { + // special case id + if strings.ToLower(name) == "id" { + return "id" + } if cfg.DefaultGraphQLFieldFormat() == LowerCamelCase { return strcase.ToLowerCamel(name) } diff --git a/internal/field/field.go b/internal/field/field.go index 6c1bc2725..04f440fb6 100644 --- a/internal/field/field.go +++ b/internal/field/field.go @@ -45,11 +45,15 @@ func NewFieldInfoFromInputs(cfg codegenapi.Config, nodeName string, fields []*in } } + var primaryKeys []string for _, field := range fields { f, err := newFieldFromInput(cfg, nodeName, field) if err != nil { return nil, err } + if f.SingleFieldPrimaryKey() { + primaryKeys = append(primaryKeys, f.FieldName) + } if err := fieldInfo.addField(f); err != nil { errs = append(errs, err) } @@ -63,6 +67,7 @@ func NewFieldInfoFromInputs(cfg codegenapi.Config, nodeName string, fields []*in } } } + fieldInfo.primaryKeys = primaryKeys if len(errs) > 0 { // we're getting list of errors and coalescing @@ -96,6 +101,8 @@ type FieldInfo struct { computedFields map[string]bool getFieldsFn bool + primaryKeys []string + // go only emailFields map[string]bool passwordFields map[string]bool @@ -128,6 +135,13 @@ func (fieldInfo *FieldInfo) IsComputedField(f string) bool { return fieldInfo.computedFields[f] } +func (fieldInfo *FieldInfo) SingleFieldPrimaryKey() string { + if len(fieldInfo.primaryKeys) == 1 { + return fieldInfo.primaryKeys[0] + } + return "" +} + func (fieldInfo *FieldInfo) addField(f *Field) error { name := NormalizedField(f.FieldName) if fieldInfo.cols[f.dbName] != nil { diff --git a/internal/graphql/generate_ts_code.go b/internal/graphql/generate_ts_code.go index ef77481cc..14151e620 100644 --- a/internal/graphql/generate_ts_code.go +++ b/internal/graphql/generate_ts_code.go @@ -510,10 +510,6 @@ func getFilePathForAction(cfg *codegen.Config, nodeData *schema.NodeData, action return path.Join(cfg.GetAbsPathToRoot(), fmt.Sprintf("src/graphql/generated/mutations/%s/%s_type.ts", nodeData.PackageName, strcase.ToSnake(actionName))) } -func getImportPathForAction(nodeData *schema.NodeData, action action.Action) string { - return fmt.Sprintf("src/graphql/generated/mutations/%s/%s_type", nodeData.PackageName, strcase.ToSnake(action.GetGraphQLName())) -} - func getImportPathForActionFromPackage(packageName string, action action.Action) string { return fmt.Sprintf("src/graphql/generated/mutations/%s/%s_type", packageName, strcase.ToSnake(action.GetGraphQLName())) } @@ -1223,11 +1219,15 @@ func buildGQLSchema(processor *codegen.Processor) chan *buildGQLSchemaResult { if err != nil { serr.Append(err) } + nodes, err := buildActionNodes(processor, nodeData, action) + if err != nil { + serr.Append(err) + } actionObj := gqlNode{ ObjData: &gqlobjectData{ Node: nodeData.Node, NodeInstance: nodeData.NodeInstance, - GQLNodes: buildActionNodes(processor, nodeData, action), + GQLNodes: nodes, Enums: buildActionEnums(nodeData, action), FieldConfig: fieldCfg, Package: processor.Config.GetImportPackage(), @@ -1938,7 +1938,7 @@ func addConnection(nodeData *schema.NodeData, edge edge.ConnectionEdge, fields * *fields = append(*fields, gqlField) } -func buildActionNodes(processor *codegen.Processor, nodeData *schema.NodeData, a action.Action) []*objectType { +func buildActionNodes(processor *codegen.Processor, nodeData *schema.NodeData, a action.Action) ([]*objectType, error) { var ret []*objectType for _, c := range a.GetCustomInterfaces() { _, ok := c.Action.(action.Action) @@ -1946,11 +1946,16 @@ func buildActionNodes(processor *codegen.Processor, nodeData *schema.NodeData, a ret = append(ret, buildCustomInputNode(c)) } } + input, err := buildActionInputNode(processor, nodeData, a) + if err != nil { + return nil, err + } + ret = append(ret, - buildActionInputNode(processor, nodeData, a), + input, buildActionPayloadNode(processor, nodeData, a), ) - return ret + return ret, nil } func buildActionEnums(nodeData *schema.NodeData, action action.Action) []*gqlEnum { @@ -1989,7 +1994,7 @@ func buildCustomInputNode(c *customtype.CustomInterface) *objectType { return result } -func buildActionInputNode(processor *codegen.Processor, nodeData *schema.NodeData, a action.Action) *objectType { +func buildActionInputNode(processor *codegen.Processor, nodeData *schema.NodeData, a action.Action) (*objectType, error) { // TODO shared input types across create/edit for example node := a.GetGraphQLInputName() @@ -2015,8 +2020,12 @@ func buildActionInputNode(processor *codegen.Processor, nodeData *schema.NodeDat // add id field for edit and delete mutations if a.MutatingExistingObject() { + id, err := getIDField(processor, nodeData) + if err != nil { + return nil, err + } result.Fields = append(result.Fields, &fieldType{ - Name: getIDField(processor, a.GetNodeInfo().NodeInstance), + Name: id, FieldImports: []*tsimport.ImportPath{ tsimport.NewGQLClassImportPath("GraphQLNonNull"), tsimport.NewGQLImportPath("GraphQLID"), @@ -2064,8 +2073,12 @@ func buildActionInputNode(processor *codegen.Processor, nodeData *schema.NodeDat // only want the id field for the object when editing said object if a.MutatingExistingObject() { + id, err := getIDField(processor, nodeData) + if err != nil { + return nil, err + } intType.Fields = append(intType.Fields, &interfaceField{ - Name: getIDField(processor, a.GetNodeInfo().NodeInstance), + Name: id, // we're doing these as strings instead of ids because we're going to convert from gql id to ent id Type: "string", }) @@ -2134,7 +2147,7 @@ func buildActionInputNode(processor *codegen.Processor, nodeData *schema.NodeDat result.TSInterfaces = []*interfaceType{intType} } - return result + return result, nil } func getPayloadNameFromAction(a action.Action) string { @@ -2451,7 +2464,10 @@ func buildActionFieldConfig(processor *codegen.Processor, nodeData *schema.NodeD }) } - idField := getIDField(processor, nodeData.NodeInstance) + idField, err := getIDField(processor, nodeData) + if err != nil { + return nil, err + } if action.HasInput(a) { // have fields and therefore input @@ -2547,9 +2563,12 @@ func getDeletedField(processor *codegen.Processor, node string) string { return codegenapi.GraphQLName(processor.Config, fmt.Sprintf("deleted%sID", node)) } -func getIDField(processor *codegen.Processor, node string) string { - // TODO this should just be id but that should be a different PR - return codegenapi.GraphQLName(processor.Config, fmt.Sprintf("%sID", node)) +func getIDField(processor *codegen.Processor, nodeData *schema.NodeData) (string, error) { + pkey := nodeData.FieldInfo.SingleFieldPrimaryKey() + if pkey == "" { + return "", fmt.Errorf("no single field primary key for %s", nodeData.Node) + } + return codegenapi.GraphQLName(processor.Config, pkey), nil } func getEdgeField(processor *codegen.Processor, edge *edge.AssociationEdge) string {