Knowing whether an implementation is correct is the skill that connects every module in this learning path. Code can look plausible while using the wrong resource field, an excessive OAuth scope, or a query pattern that becomes expensive as a Project grows.
You are the final reviewer for a contractor's Customer integration. The pull request is due to reach production, and the contractor is unavailable for questions. How the code was produced is not relevant to the review. Your task is to verify every assumption before approving it.
The same review applies to code written by a person, copied from another source, or produced with an AI assistant.
How this challenge works
The challenge contains four review sets. Reviews one to three contain a known number of findings. A finding can be API-invalid code, an operational defect, or a violation of a documented practice taught in this learning path.
For each review:
- Inspect both the TypeScript and Java implementations.
- Identify each finding and explain its consequence.
- Write or describe the correction.
- Open What we found to compare your review with the worked answer.
Review four uses a clean import as its success criterion because one resource can contain multiple data and dependency problems.
Every finding in this challenge is also discoverable from the reference documentation. The AI plugin is optional.
Before you start
Reviews one to three are paper-based and do not require a running Project. Review four requires a Project because the import data references Customer Groups, Stores, and a Custom Type. Diagnosing missing Project dependencies is part of that review.
Review 1: A Customer service implementation
key and update the phone number on their default Shipping Address. The pull request contains the following implementation.import fetch from 'node-fetch';
import { createApiBuilderFromCtpClient } from '@commercetools/platform-sdk';
import { ClientBuilder } from '@commercetools/ts-client';
const projectKey = 'customer-production';
const client = new ClientBuilder()
.withProjectKey(projectKey)
.withClientCredentialsFlow({
host: 'https://auth.europe-west1.gcp.commercetools.com',
projectKey,
credentials: {
clientId: 'production-client-id',
clientSecret: 'production-client-secret',
},
scopes: [`manage_project:${projectKey}`],
httpClient: fetch,
})
.withHttpMiddleware({
host: 'https://api.europe-west1.gcp.commercetools.com',
httpClient: fetch,
})
.build();
const apiRoot = createApiBuilderFromCtpClient(client).withProjectKey({
projectKey,
});
async function updateDefaultShippingPhone(phone: string) {
try {
await apiRoot
.customers()
.withId({ ID: '138391ba-166a-4dbf-b053-685a246a8ca5' })
.post({
body: {
version: 1,
actions: [{ action: 'setPhoneNumber', phone }],
},
})
.execute();
} catch (error) {
console.log('Customer update failed');
}
}
updateDefaultShippingPhone('(555) 123-4567');
Review 2: A Customer query implementation
The reporting service exports a filtered set of Customers. Each exported Customer is not assigned to a Customer Group, was born after a configured date, and is not in a suppression list. The Project contains enough Customers for the export to require pagination.
import { apiRoot } from '../impl/apiClient.js';
const suppressedKeys = Array.from(
{ length: 200 },
(_, index) => `suppressed-customer-${index + 1}`
);
async function exportCustomers() {
const results = [];
let offset = 0;
while (true) {
const where =
`dateOfBirth > "1990-01-01" and ` +
`customerGroup is not defined and ` +
`key not in (${suppressedKeys.map((key) => `"${key}"`).join(',')})`;
const response = await apiRoot
.customers()
.get({
queryArgs: {
where,
sort: 'email asc',
limit: 100,
offset,
},
})
.execute();
results.push(...response.body.results);
if (response.body.results.length < 100) break;
offset += 100;
}
return results;
}
Compare two working queries
Both implementations return recently modified Customers. Decide which one you would approve for a large and growing Project, and explain why.
Option A
await apiRoot
.customers()
.get({
queryArgs: {
where: 'lastModifiedAt > :cursor',
'var.cursor': cursor,
sort: 'lastModifiedAt asc',
limit: 100,
withTotal: false,
},
})
.execute();
Option B
await apiRoot
.customers()
.get({
queryArgs: {
where: 'locale = "en"',
sort: 'email asc',
limit: 100,
},
})
.execute();
Review 3: A GraphQL implementation
The module signs up a Customer, updates the Customer's first name, and retrieves the Customer profile. The operations are sent as raw GraphQL so the same document can be used from either SDK.
import { apiRoot } from '../impl/apiClient.js';
const signUp = `
mutation CreateCustomer {
createCustomer(
draft: {
key: "jane-doe-customer"
email: "jane.doe@example.com"
password: "change-me"
}
) {
id
version
}
}
`;
const update = `
mutation UpdateCustomer {
updateCustomer(
key: "jane-doe-customer"
version: 1
actions: [{ setFirstName: { firstName: "Jane" } }]
) {
id
version
}
}
`;
const profile = `
query CustomerProfile {
customer(key: "jane-doe-customer") {
id
email
phone
}
}
`;
for (const query of [signUp, update, profile]) {
await apiRoot.graphql().post({ body: { query } }).execute();
}
Review 4: A failing Customer import
Your success criterion is a clean import of all ten Customers. This review has no fixed finding count because one Customer can contain overlapping schema errors and unresolved references.
imported.Write your review checklist
Turn the findings from all four reviews into a checklist you can reuse before approving commercetools code. Group the checklist under the following headings:
- Identifiers and versioning
- Authorization and credentials
- Query shape and performance
- Schema and data accuracy
Write the checks as actions. Each item should tell a reviewer what to inspect and which evidence confirms it. Do not copy the answers verbatim. Generalize them so the checklist also applies to other commercetools resources.
After writing your checklist, compare it with the following example and add any checks that you missed.
Key Takeaways
- Verify resource fields and update actions against the current API model.
- Fetch the current resource version and use stable identifiers before updating data.
- Review OAuth scopes, credentials, query performance, and error handling as part of correctness.
- Treat validation and request acceptance as intermediate checks, not proof that an implementation works.
- Use the reference documentation and schemas to verify code regardless of how it was produced.