Skip to main content

People

A shared package that exports queries, mutations, types, and utility functions for people.

Usage​

The module has been imported into our root npm package. All you have to do is import it into your module.

import { Person } from '@shared/people'

Exported Queries​

usePeopleQuery​

Fetches a paginated list of people from the public-api people endpoint. You are able to pass an optional set of query params and optionally override the underlying UseQueryOptions.

const { data, isLoading } = usePeopleQuery(queryParams)

getPeople​

Fetches a paginated list of people from the public-api people endpoint. You are able to pass an optional set of query params and optionally override the underlying UseQueryOptions.

This is only to be used outside of React. If you are in React please use the hook.

const { data } = await getPeople(queryParams)

Exported Types​

TypeDescription
PersonPerson resource returned by our public apis

Exported Utilities​

We provide useful utilities for interacting with the People.

Utility FunctionDescription
formatPersonForDisplayFormat a person by their display name or email address

Private api Usage​

import { privatePeopleApi } from '@shared/people'

Exported Private Queries​

usePersonQuery​

Fetches a person from the private-api person endpoint. You are able to pass an optional set of query params and optionally override the underlying UseQueryOptions.

const { data, isLoading } = usePersonQuery(number, PersonQueryOptions)

invalidatePersonQuery​

Function to invalidate the person query

import { privatePeopleApi } from '@shared/people'

privatePeopleApi.queries.invalidatePersonQuery()

setPersonQueryData​

Function to set the person query

import { privatePeopleApi } from '@shared/people'

privatePeopleApi.queries.setPersonQueryData(number, Person)

Exported Private Mutations​

updatePersonMutation​

Function to update the person. You are able to pass an optional set of query params and optionally override the underlying UseQueryOptions.

import { privatePeopleApi } from '@shared/people'

privatePeopleApi.mutations.updatePersonMutation(PersonQueryOptions)

deletePersonMutation​

Function to delete the person. You are able to pass an optional set of query params and optionally override the underlying UseQueryOptions.

import { privatePeopleApi } from '@shared/people'

privatePeopleApi.mutations.deletePersonMutation(PersonQueryOptions)

Exported Private Mocks​

Private person mocks

import { privatePeopleApi } from '@shared/people'

privatePeopleApi.mocks.melodyPersonMock

Exported Private Types​

import { PrivateApiPersonType } from '@shared/people'
TypeDescription
PersonPerson resource returned by our private api
PersonFieldsPerson fields type