Inflation is roiling the economy, with consumer prices up nearly 10% since a year ago in both the U.S. and Europe. The stock market had its worst first half in more than 50 years, and retail giants like Walmart are slashing profit guidance due to inflation weighing on consumer discretionary spending.

In this environment, with fears of a recession swirling around much of the global economy, you might expect GXO Logistics (GXO 3.26%), the world's biggest pure-play contract logistics company, to be experiencing headwinds. But its second-quarter earnings report showed everything except that.

Strong Q2 performance for this young company

Organic revenue in the quarter was up 20% year over year, leading overall revenue to jump 15% to $2.16 billion, ahead of estimates at $2.11 billion. (A foreign currency headwind explains the difference between organic and reported revenue.) On the bottom line, adjusted earnings per share jumped 55% to $0.68, beating estimates at $0.62.

GXO, which IPO'd roughly one year ago, is capitalizing on a number of trends, including growth in e-commerce and outsourcing, and its ability to deliver speed and cost efficiencies to its customers in various sectors including retailing, consumer packaged goods, healthcare, and industrials. And even as a number of its customers are fighting inflation themselves, GXO has managed to resist the cost pressures.

GXO versus inflation

There are a number of reasons GXO has been able to absorb rising costs. First, 45% of its revenue comes from cost-plus contracts, meaning the company charges customers a given percentage on top of its own costs, enabling it to easily pass along increases for things like labor, rent, or utilities.

The remainder of its revenue generally includes escalators to account for inflation, which helps explain why its margins actually expanded during the quarter.

Its cost structure also leans toward variable costs rather than fixed costs with 71% being variable and 29% fixed, meaning that costs will rise and fall along with revenue, helping to protect it from a downturn. The company's contracts also include minimum-volume guarantees so customers have to commit to ship a certain volume with it or pay the difference, giving it a hedge against a recession or inflation that might be pressuring its customers.

With an average length of five years and getting longer, GXO's contracts also give it a lot of visibility into future revenue, allowing the company to plan for steady growth.

Why GXO is outperforming

Even as some companies cut back on investments, GXO continues to deliver strong growth because of the cost savings it provides, as its chief investment officer, Mark Manduca, explained in an interview with The Motley Fool.

One example Manduca gave is its reverse logistics business, handling companies' product returns. Product returns are a big challenge in e-commerce, and for some companies, as many as one-in-three products purchased are shipped back. GXO can help its customers process those returns and get them back in stores or available online in a matter of days, which is crucial for seasonal businesses like fast fashion.

Reverse logistics has become a high-margin business for GXO because it helps its customers save money. It now makes up roughly 10% of total revenue and plays a role in about 40% of its customer relationships. It's also one reason the company's customer retention rate is now in the mid- to high-90% range since it enhances customer satisfaction, and the automation involved helps lock customers into the relationship.

GXO raises guidance

The company also raised its revenue and adjusted EBITDA guidance for the year, a further sign of its confidence. Management now expects 12% to 16% organic revenue growth for the year, up from a prior forecast of 11% to 15%. And it raised its adjusted EBITDA target from the range of $707 million to $742 million, to a range of $715 million to $750 million.

Over the long term, the growth opportunity for GXO looks bright as it penetrates a large, fragmented market through organic growth and acquisitions like its just-completed takeover of Clipper Logistics

If GXO can deliver strong numbers in an economy with high inflation, recession fears, and sluggish e-commerce growth, the stock is a good bet to thrive in any environment.