2017-11-20 2 views
0

以下のコードのリクエストはすべてOKですが、データは返されません(chromeのリクエストの「プレビュー」タブに「エラーが見つかりません」と表示されます)。 )。私はGraphiQLで同じクエリを試して、関連するデータを返します。私はここで何が欠けているのか分かりません。これにこだわったことをアドバイスしてください。

あなたは、データ本体を送信するように見える
PlayService.prototype.getPlays = function(playID) { 
//The query. 
const playsQuery = `query ($playid: String) { 
    plays(id: $playid) { 
     id 
     items { 
     nodes { 
      id 
      name 
     } 
     } 
    } 
    }`; 

    // variables to pass. 
    const variables = { 
    playid: playID 
    }; 

    //The request. 
    const result = $http.post(
    /graphql, 
    { 
     method: 'POST', 
     credentials: 'same-origin', 
     headers: { 
     'Content-Type': 'application/json' 
     }, 
     body: JSON.stringify({ playsQuery, variables }) 
    } 
); 
    return result && result.data; 
}; 

答えて

0

:GraphQL仕様は、あなたがREST経由GraphQLクエリのために、この形式に従わなければならないことを指定し

{ 
    playsQuery: "<query string>", 
    variables: {} 
} 

http://graphql.org/learn/serving-over-http/

{ 
    "query": "...", 
    "operationName": "...", 
    "variables": { "myVariable": "someValue", ... } 
} 
関連する問題