This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
MPDX is a Next.js 15 React application using the Pages Router with TypeScript and Material UI v7.
The application uses two GraphQL servers:
- GraphQL API Server (
https://api.mpdx.org/graphql) - Primary GraphQL API - REST Proxy Server (
/api/graphql-rest) - Next.js lambda that converts REST to GraphQL
Apollo Link automatically routes queries based on which fields are requested. Check src/graphql/rootFields.generated.ts to see which fields are available from the GraphQL API server.
- Components are organized by feature/page in
src/components/ - Shared components are in
src/components/Shared/ - Test files live next to the component they test
- GraphQL operations live next to the component that uses them
- Operations: Use descriptive names, not starting with "Get" or "Load" (e.g.,
ContactDetails,UpdateContact) - Files: PascalCase with
.graphqlextension matching component name - Generated files: Auto-generated as
.generated.ts
- Always include
idfields in queries/mutations for Apollo cache normalization - Run
yarn gqlafter any GraphQL file changes - Handle pagination - most
nodesfields are paginated (default 25 items) - Use proper imports: Import generated hooks from
.generated.tsfiles
query ContactNames($accountListId: ID!, $after: String) {
contacts(accountListId: $accountListId, after: $after, first: 50) {
nodes {
id
name
}
pageInfo {
endCursor
hasNextPage
}
}
}When adding queries that need REST API data:
- Copy existing query folder in
pages/api/Schema/ - Define GraphQL schema in
.graphqlfile - Run
yarn gqlto generate types - Implement REST API call in
graphql-rest.page.ts - Create data handler for response transformation
- Add resolvers to call the data handler
- Register in
pages/api/Schema/index.ts
Use GqlMockedProvider to mock GraphQL responses:
import { GqlMockedProvider } from '__tests__/util/graphqlMocking';
const mutationSpy = jest.fn();
it('loads contact data', async () => {
const { findByText } = render(
<GqlMockedProvider<{ ContactDetails: ContactDetailsQuery }>
mocks={{
ContactDetails: {
contact: {
name: 'John Doe',
},
},
}}
onCall={mutationSpy}
>
<ContactComponent />
</GqlMockedProvider>,
);
expect(await findByText('John Doe')).toBeInTheDocument();
await waitFor(() =>
expect(mutationSpy).toHaveGraphqlOperation('ContactDetails', {
contactId: 'contact-1',
}),
);
});yarn test ComponentName.test.tsx # Run specific test file- Components: PascalCase (e.g.,
ContactDetails.tsx) - Pages: kebab-case with
.page.tsx(e.g.,contact-details.page.tsx) - Tests: Same as file +
.test.tsx - GraphQL: PascalCase
.graphqlfiles
- Always use named exports (never default exports)
- Component exports:
export const ComponentName: React.FC = () => {}
All user-visible text must be localized using useTranslation:
const { t } = useTranslation();
return <h1>{t('Dashboard')}</h1>;The app supports two auth providers via AUTH_PROVIDER env var:
OKTA(default) - requiresOKTA_*variablesAPI_OAUTH- requiresAPI_OAUTH_*variables
Critical environment setup:
- Get
.envfile from another developer - Install Node v22.14.0 (use asdf version manager)
- Install Git LFS:
git lfs pull - Run
yarn && yarn gql && yarn start