Only first element of tuple matches

I have the following rule and query:

rule_path(myRelation,
  [relation1-EntityType1,
   relation2-EntityType2,
   relation3-EntityType3,
   relation4-EntityType4]).

next_step(QueryRelation, [], NextRelation, NextEntity) :-
    rule_path(QueryRelation, [NextRelation-NextEntity|_]).

% Query:
% ?- next_step(myRelation, [], NextRelation, NextEntity).

However, I only got the NextRelation back as answer, instead of NextRelation-NextEntity. Do you have any idea what might be the problem? Thank you

It’s not clear to me what you’re trying to do (e.g., what is the [] in next_step/4?), but maybe this is what you want:

next_step(QueryRelation, [], NextRelation, NextEntity) :-
    rule_path(QueryRelation, Paths),
    member(NextRelation-NextEntity, Paths).
?- next_step(myRelation, [], NR, NE).
next_step(myRelation, [], NR, NE).
NR = relation1 ;
NR = relation2 ;
NR = relation3 ;
NR = relation4.

relation1 is lower-case, therefore an atom, therefore data.

EntityType1 begins with a capital letter, so is a variable rather than data.

It’s like stating:

?- X = _.
true.

… which isn’t useful and doesn’t instantiate X.

Ok, if I change the relation1 to uppercase, I get back true.

What I’m trying to do is to define, entity types, relation types connecting these entities, and named paths in a graph. Based on the path name (QueryRelation) and the steps taken so far, I want to get back the next valid step, i.e., next valid relation and entity.