Im wondering if there's an existing literature on this binary operation involving graphs wherein you identity $n$ vertices from one graph with $n$ vertices from the other such that the resulting structure is still a graph (no loops and multiple edges). For instance, given two paths $[a,b,c]$ and $[d,e,f]$, letting $a=f$ and $c=d$ produces $C_4$.
Since I cannot add comments, I put this as an answer. I do not know about specific graph-theoretical literature about the operation you describe, but it seems that it can be exhibited as a pushout in a suitable category.
For simplicity, I suppose you consider only undirected graphs.
Take the category where objects are sets equipped with a reflexive and symmetric relation, and where a morphism $h: (A,\alpha)\to(B,\beta)$ is an (ordinary) map of sets $h:A\to B$ that satisfies $\forall a,a'\in A: (a,a')\in\alpha\Rightarrow (ha,ha')\in\beta$.
Then the objects of that category correspond to (undirected simple) graphs and therefore also give a notion of graph homomorphism. Let $1$ be the graph with exactly one vertex and write $n$ for the discrete graph with $n$ vertices. Then, given two graphs $G$ and $H$, choosing $n$ vertices in $G$ and $H$ is the same as giving monomorphisms $n\to G$ and $n\to H$, and your gluing operation is then given as a pushout of $G\leftarrow $n$ \rightarrow H$
Have a look at this:
I think that what van der Holst calls Separations is what you need.