# Canonical Party: GraphQL surface reflected by pg_graphql from the canonical_party ODS tables. # # This file documents the contract consumers can rely on. It is not loaded anywhere; the live # schema is reflected from the tables and available by introspection: # curl http://localhost:3000/rpc/canonical_party_graphql -H 'Content-Type: application/json' \ # --data '{"query":"{ __type(name: \"Party\") { fields { name } } }"}' # # Naming (inflect_names: true): table party_role -> type PartyRole; column role_status -> roleStatus. # Scalars: uuid -> UUID, text -> String, boolean -> Boolean, date -> Date, timestamptz -> Datetime. # A relationship field backed by a NOT NULL foreign key is non-null (Party!). # # Relationship fields are derived from the foreign keys. Two cases need the @graphql directives # set in ods/020_tables.sql: the subtype primary-key-as-foreign-key (Person, Company, Customer), # which otherwise reflects as Person.person / Party.person, and the two foreign keys from # party_association to party, which otherwise produce two identical partyAssociationCollection # fields on Party. The names below are what the directives produce. type Party implements Node { nodeId: ID! partyId: UUID! partyType: String! # discriminator: 'Person' | 'Company' legalName: String! alsoKnownAs: String # semicolon-separated; see template/README.md type mapping partyStatus: String # enum:Party Status, enforced by CHECK in the ODS createdAt: Datetime! updatedAt: Datetime! person: Person # subtype row, when partyType = 'Person' company: Company # subtype row, when partyType = 'Company' partyRoleCollection(first: Int, after: Cursor, filter: PartyRoleFilter, orderBy: [PartyRoleOrderBy!]): PartyRoleConnection contactAddressCollection(first: Int, after: Cursor, filter: ContactAddressFilter, orderBy: [ContactAddressOrderBy!]): ContactAddressConnection outgoingAssociationCollection(first: Int, after: Cursor, filter: PartyAssociationFilter, orderBy: [PartyAssociationOrderBy!]): PartyAssociationConnection # this party is source_party_id incomingAssociationCollection(first: Int, after: Cursor, filter: PartyAssociationFilter, orderBy: [PartyAssociationOrderBy!]): PartyAssociationConnection # this party is target_party_id } type Address implements Node { nodeId: ID! addressId: UUID! addressType: String # enum:Address Type addressLine1: String addressLine2: String suburb: String city: String stateOrRegion: String postcode: String country: String! createdAt: Datetime! updatedAt: Datetime! contactAddressCollection(first: Int, after: Cursor, filter: ContactAddressFilter, orderBy: [ContactAddressOrderBy!]): ContactAddressConnection } type Person implements Node { nodeId: ID! personId: UUID! # equals the extended party's partyId dateOfBirth: Date preferredName: String countryOfResidence: String createdAt: Datetime! updatedAt: Datetime! party: Party! # from person_id (extends Party) } type Company implements Node { nodeId: ID! companyId: UUID! # equals the extended party's partyId companyRegistrationNumber: String incorporationCountry: String incorporationDate: Date legalStructure: String # enum:Company Legal Structure taxIdentifier: String createdAt: Datetime! updatedAt: Datetime! party: Party! # from company_id (extends Party) } type PartyRole implements Node { nodeId: ID! partyRoleId: UUID! partyRoleType: String! # discriminator: 'Customer' roleStatus: String # enum:Party Role Status roleStartDate: Date roleEndDate: Date partyId: UUID! createdAt: Datetime! updatedAt: Datetime! party: Party! # from party_id (Party Assumes Roles) customer: Customer # subtype row, when partyRoleType = 'Customer' partyRoleContactAddressCollection(first: Int, after: Cursor, filter: PartyRoleContactAddressFilter, orderBy: [PartyRoleContactAddressOrderBy!]): PartyRoleContactAddressConnection } type Customer implements Node { nodeId: ID! customerId: UUID! # equals the extended role's partyRoleId customerNumber: String! # unique business key onboardingDate: Date relationshipStartDate: Date createdAt: Datetime! updatedAt: Datetime! partyRole: PartyRole! # from customer_id (extends Party Role) } type ContactAddress implements Node { nodeId: ID! contactAddressId: UUID! addressPurpose: String # enum:Address Purpose isPrimary: Boolean verificationStatus: String # enum:Address Verification Status verificationDate: Date verificationMethod: String # enum:Verification Method validFrom: Date validTo: Date partyId: UUID! addressId: UUID! createdAt: Datetime! updatedAt: Datetime! party: Party! # from party_id (Party Has Contact Addresses) address: Address! # from address_id (Contact Address References Address) partyRoleContactAddressCollection(first: Int, after: Cursor, filter: PartyRoleContactAddressFilter, orderBy: [PartyRoleContactAddressOrderBy!]): PartyRoleContactAddressConnection } type PartyRoleContactAddress implements Node { nodeId: ID! partyRoleContactAddressId: UUID! partyRoleId: UUID! contactAddressId: UUID! createdAt: Datetime! updatedAt: Datetime! partyRole: PartyRole! # from party_role_id contactAddress: ContactAddress! # from contact_address_id } type PartyAssociation implements Node { nodeId: ID! partyAssociationId: UUID! sourcePartyId: UUID! targetPartyId: UUID! associationType: String # enum:Association Type associationStartDate: Date associationEndDate: Date verified: Boolean createdAt: Datetime! updatedAt: Datetime! sourceParty: Party! # from source_party_id targetParty: Party! # from target_party_id } extend type Query { partyCollection(first: Int, last: Int, before: Cursor, after: Cursor, filter: PartyFilter, orderBy: [PartyOrderBy!]): PartyConnection addressCollection(first: Int, last: Int, before: Cursor, after: Cursor, filter: AddressFilter, orderBy: [AddressOrderBy!]): AddressConnection personCollection(first: Int, last: Int, before: Cursor, after: Cursor, filter: PersonFilter, orderBy: [PersonOrderBy!]): PersonConnection companyCollection(first: Int, last: Int, before: Cursor, after: Cursor, filter: CompanyFilter, orderBy: [CompanyOrderBy!]): CompanyConnection partyRoleCollection(first: Int, last: Int, before: Cursor, after: Cursor, filter: PartyRoleFilter, orderBy: [PartyRoleOrderBy!]): PartyRoleConnection customerCollection(first: Int, last: Int, before: Cursor, after: Cursor, filter: CustomerFilter, orderBy: [CustomerOrderBy!]): CustomerConnection contactAddressCollection(first: Int, last: Int, before: Cursor, after: Cursor, filter: ContactAddressFilter, orderBy: [ContactAddressOrderBy!]): ContactAddressConnection partyRoleContactAddressCollection(first: Int, last: Int, before: Cursor, after: Cursor, filter: PartyRoleContactAddressFilter, orderBy: [PartyRoleContactAddressOrderBy!]): PartyRoleContactAddressConnection partyAssociationCollection(first: Int, last: Int, before: Cursor, after: Cursor, filter: PartyAssociationFilter, orderBy: [PartyAssociationOrderBy!]): PartyAssociationConnection } # Every type has the same three mutations; shown once for Party. extend type Mutation { insertIntoPartyCollection(objects: [PartyInsertInput!]!): PartyInsertResponse updatePartyCollection(set: PartyUpdateInput!, filter: PartyFilter, atMost: Int! = 1): PartyUpdateResponse deleteFromPartyCollection(filter: PartyFilter, atMost: Int! = 1): PartyDeleteResponse # ... insertIntoAddressCollection, updateAddressCollection, deleteFromAddressCollection, and so on # for Person, Company, PartyRole, Customer, ContactAddress, PartyRoleContactAddress, PartyAssociation. }