With road tyres it's easy to get a rim that's wider than the tyre itself. Generally speaking just avoid that. So for example a 25mm outside diameter rim and 28mm tyre is fine, but if you go wider with the rim you might have problems. What i've seen a lot is when the rim is too wide the bead of the tyre can't go up into the bead of the rim, it sits lower, therefore you have a huge bump in the tyre. There is a technique to pull it out, but it's not an ideal situation.
I'd say don't go wider than 20mm ID if you really want to use 28mm tyres, but if it's your first gravel bike you're going to end up using wider tyres all the time anyways, you'll see.
The ETRTO guidline is fine but for 40mm tyres i'd prefer a 20mm, nothing narrower. And watch out because these light 18mm 24 spoke rims are just plain old road bike wheels, not necessarily suitable for offroad.
I want to use this bike for road riding and road racing mostly and just few times a month for cyclocross/crosscountry/gravel riding and racing. Wanted to have just one light wheelset and two sets of tires. What would you recommend - to chose 700x32 and 700x40 or 700x28 and 700x38 with those wheelsets from DT swiss? Or you think this wheelset will be broken on the first crosscountry ride?