Suppose I want to expand a macro argument to a tikz command a single time. If this was a normal macro defined with braces I'd know how to use expandafter to do it but I don't know where to put them with a tikz command since I'm not sure how it parses it's command and it's not nicely broken up with braces. Do I need expandafters for each token that appears in the tikz command before the argument I want expanded?
In particular, how would I define the macro \drawnode below so it expands it's argument once before inserting it. I'm fine with solutions based on something besides expandafter like edef.
\NewDocumentCommand{\drawnode}{m} {\node[draw,circle,minimum size=2.2mm,black] (foo) at (0,0) #1}
In other words, how would I change \drawnode to made the following code work.
\documentclass{standalone}
\usepackage{unicode-math}
\setmainfont{XITS}
\setmathfont{XITS Math}
\setmathfont{XITS Math}[range={\mathscr,\mathbfscr}]
\setmathfont{XITS Math}[range={\mathcal,\mathbfcal},StylisticSet=1]
\usepackage{tikz}
\NewDocumentCommand{\drawnode}{m} {\node[draw,circle,minimum size=2.2mm,black] (foo) at (0,0) #1}
\newcommand{\drawagain}{; \node (rect) at (4,2) [draw,thick,minimum width=2cm,minimum height=2cm] {};}
\begin{tikzpicture}
\drawnode{\drawagain}
\end{tikzpicture}
\end{document}

#1is the last thing in the definition of\drawnode(which is defined with four arguments for some reason, but I guess that's a typo), you could just make it take no arguments at all and do\expandafter\drawnode\drawagain. However, this would still not work with your example, not because of some expansion issue, but because you did not provide any node text. Could you change your MWE to something that more clearly shows what you want to do? – schtandard Feb 09 '21 at 17:41