I was wrongly diagnosed with anorexia when I got sick and was losing weight. Being a teenage girl at the time didn't help.
You will at least be in a position where medical professionals will recognise that you have another cause for the weight loss - they should take the surgery into account, depending on how big an operation it is and how you're affected by the aneasthetic (can make you feel sick for a while after) and the healing (stomach pain can interfere with eating).
I would try to gain as much as you can before the operation, and speak to your doctors about ways to keep your weight up during and after surgery. They will probably ask you about this anyway - weight and nutrition should be assessed in your appointments leading up to the surgery as a standard part of assessing you before the operation. They may be able to provide you with supplements, a dietician, or a meal plan. You'll probably be on soft foods for a while after. Some weight loss will be expected, and the doctors should be making sure it's a safe amount for you.
Diarrhoea doesn't necessarily mean weight loss. E.g. the colon absorbs water but not calories, so if you have it removed you have more water in your bowel movements, but it won't affect the amount of calories you absorb.
Is it family whose judgements you are worried about or doctors or someone else?
Hopefully if the surgery fixes things in the long run maintaining weight - and feeling better - will be easier.