Transform apollo-datasource-rest response structure to adapt to the already defined remote schema

橙三吉。 提交于 2019-12-13 03:56:12

问题


We have remote schema already. We get Apollo datasource response by hitting the REST APIs using apollo-datasource-rest. The format of the json response does not match the schema. The task is to transform the json response to match the schema and return the result against the user query. How to achieve this?

E.g REST API response:

{
    "members": {
        "name": "john",
        "street_address": "10 Barley St."
    }
}

Our remote graphql schema:

type Users {
    username: String!
    street: String!
}

Any ideas or help or source code is highly appreciated. Thanks again.

来源:https://stackoverflow.com/questions/58723005/transform-apollo-datasource-rest-response-structure-to-adapt-to-the-already-defi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!