title: AWS AppSync Subscription fails during handshake
body: <p>I'm trying to set up a graphql subscription but I'm getting the error:</p>
  
  <pre><code>Unhandled GraphQL subscription error Error: Error during subscription handshake
  </code></pre>
  
  <p>I'm using AWS Cognito User Pools for the authorisation.</p>
  
  <p>To create the Subscription I'm using: </p>
  
  <pre><code>this.subscription = this.props.client.subscribe({ query: gql(onCreateVehicle) }).subscribe({
    next: response =&gt; {
      console.log(response.data.onCreateVehicle);
    },
    error: error =&gt; {
      console.warn(error);
    }
  });
  </code></pre>
  
  <p>'onCreateVehicle' was automatically generated by Amplify and looks like this:</p>
  
  <pre><code>export const onCreateVehicle = `subscription OnCreateVehicle($owner: String!) {
    onCreateVehicle(owner: $owner) {
      id
      name
      events {
        items {
          id
          name
          date
          isDeleted
          owner
        }
        nextToken
      }
      sessions {
        items {
          id
          name
          isDeleted
          createdAt
          owner
        }
        nextToken
      }
      isDeleted
      owner
    }
  }
  `;
  </code></pre>
  
  <p>Request resolver:</p>
  
  <pre><code>{
      "version": "2018-05-29",
      "payload": {}
  }
  </code></pre>
  
  <p>Response resolver:</p>
  
  <pre><code>## [Start] Determine request authentication mode **
  #if( $util.isNullOrEmpty($authMode) &amp;&amp; !$util.isNull($ctx.identity) &amp;&amp; !$util.isNull($ctx.identity.sub) &amp;&amp; !$util.isNull($ctx.identity.issuer) &amp;&amp; !$util.isNull($ctx.identity.username) &amp;&amp; !$util.isNull($ctx.identity.claims) &amp;&amp; !$util.isNull($ctx.identity.sourceIp) &amp;&amp; !$util.isNull($ctx.identity.defaultAuthStrategy) )
    #set( $authMode = "userPools" )
  #end
  ## [End] Determine request authentication mode **
  ## [Start] Check authMode and execute owner/group checks **
  #if( $authMode == "userPools" )
    ## No Static Group Authorization Rules **
  
  
    ## [Start] Owner Authorization Checks **
    #set( $isOwnerAuthorized = false )
    ## Authorization rule: { allow: owner, ownerField: "owner", identityClaim: "cognito:username" } **
    #set( $allowedOwners0 = $util.defaultIfNull($ctx.args.owner, null) )
    #set( $identityValue = $util.defaultIfNull($ctx.identity.claims.get("username"),
                          $util.defaultIfNull($ctx.identity.claims.get("cognito:username"), "___xamznone____")) )
    #if( $util.isList($allowedOwners0) )
      #foreach( $allowedOwner in $allowedOwners0 )
        #if( $allowedOwner == $identityValue )
          #set( $isOwnerAuthorized = true )
        #end
      #end
    #end
    #if( $util.isString($allowedOwners0) )
      #if( $allowedOwners0 == $identityValue )
        #set( $isOwnerAuthorized = true )
      #end
    #end
    ## [End] Owner Authorization Checks **
  
  
    ## [Start] Throw if unauthorized **
    #if( !($isStaticGroupAuthorized == true || $isOwnerAuthorized == true) )
      $util.unauthorized()
    #end
    ## [End] Throw if unauthorized **
  #end
  ## [End] Check authMode and execute owner/group checks **
  
  $util.toJson(null)
  </code></pre>
  
  <p>I know it has something to do with authorisation as it didn't throw the handshake error when I removed the @auth from the schema.graphql. Should there be something in the request resolver to handle the authorisation?</p>
  
  <p>Adam</p>