title: GraphQL: Accepting a query response with a missing requested field?
body: <p>I have an Apollo GraphQL query to fetch movies from my backend, and the backend conditionally adds extra fields to the response if detects an user with an open session (an authentication cookie).</p>
  <p>The thing is that the frontend uses the same query whether a user is logged in or not, and always requests an <strong>user-dependent field</strong> indicating if the movie is in the users's collection, and does this even if there is no user logged in, as it's the backend the one which decides.</p>
  <p>Of course, when no user is logged in and the frontend asks for that field, the backend decides not to send it and send only the public fields (title, genre...) and the requests ends in error. I have two solutions for this, but I don't like either:</p>
  <ol>
  <li><p><strong><code>Add a variable to the query with @include</code></strong>, indicating whether a user is logged in or not to fetch the field
  conditionally.
  I don't like it because it seems redundant, since the backend already checks this automatically by
  looking for active sessions in the context (a cookie is included in the request). This solution would be ok if I could add the variable just in the frontend query.</p>
  </li>
  <li><p><strong><code>Make the backend always send the field</code></strong>, even if no user is logged in, in which case
  it sends it empty or false. I don't like it because it's unnecessary traffic, specially considering
  that I plan to add many other user specific fields (ratings, etc), and that I expect many users to
  use the app unauthenticated.</p>
  </li>
  </ol>
  <hr />
  <h2>TLDR</h2>
  <p>So my question is:</p>
  <p>Is there any way of requesting a field in a GraphQL query and accepting the response even if it does not include that field at all (not even undefined) while still requiring the other fields?. What would be the best way to approach this issue using just one query?</p>
  <p>I am trying to do this with a single query to avoid having to chain queries in my frontend.</p>