title: Relay - set variable before query
body: <p>I'm currently working on a page that displays the status of a certain set of "tasks" for a specific user. To fetch the data, I have the following Relay container:</p>
  
  <pre class="lang-js prettyprint-override"><code>export default Relay.createContainer(TaskReview, {
    initialVariables: {
      limit: Number.MAX_SAFE_INTEGER,
      studentId: null,
    },
    fragments: {
      task: () =&gt; Relay.QL`
        fragment on Task {
          id,
          title,
          instruction,
          end_date,
          taskDataList(first: $limit, type: "subTasks", member: $studentId) {
            edges {
              node {
                id,
                answer,
                completion_date,
              }
            }
          },
          ...
  </code></pre>
  
  <p>To define which user I want to get data from, I use:</p>
  
  <pre class="lang-js prettyprint-override"><code>componentWillMount = () =&gt; {
    let {relay} = this.props;
    relay.setVariables({
      studentId: this.props.member.id
    });
  }
  </code></pre>
  
  <p>However, the problem here is that the query is first executed with <code>null</code> as defined in <code>initialVariables</code>. My backend implementation has it so that if the <code>studentId</code> is NULL, then it returns the data for all members.</p>
  
  <p>The result is that the above query executes twice, the first time with all members, and the second time with the given <code>memberId</code>.</p>
  
  <p>This messes up with other things within my <code>componentWillUpdate</code>. Is there anyway I can pass this variable and only get the data for that member on the first query?</p>
  
  <p>Thanks.</p>