如何请求不带扩展名的graphql查询?

时间:2019-10-01 04:34:25

标签: graphql apollo absinthe

嗨,我想从服务器请求graphql查询。但是它总是在扩展名字段中返回一堆日志。我的问题是如何修改下面的graphql查询以放弃扩展名。这是我的graphql查询:


    query {
        myProfile {
            id,
            email,
            name,
            role,
            phoneNumber,
            phoneNumberVerified,
            accountType,
            avatar{
                full,
                preview,
            }
            status,
            vehiclesCount,
            vehicles {
                id,
                vehicleType,
                subType,
                licenseNumber,
                status,
                ... on OwnVehicle {
                    stnk {
                        id,
                        url {
                            full,
                            preview,
                        }
                    }
                },
                rejectMessage
            }
            baseInformation {
                id,
                address,
                ownerName,
                city,
                postalCode
            },
            bankInformation {
                id,
                bankName,
                accountNumber,
                accountHolder
            },
            documentInfo {
                id,
                documentType {
                    id,
                    name,
                },
                documentGroupName,
                url {
                    full,
                    preview,
                },
                documentVerification {
                    status,
                    reason,
                    message
                }
            },
            ratingInfo {
                average,
                count,
            },
            ... on CompanyTransporter {
                representativeInformation {
                    id,
                    name,
                    title,
                    email,
                    phoneNumber,
                }
            }
        }
    }

这是响应:

{
    "data": {
        "myProfile": {
            "id": "1QwyGIMTbD4cWgDLORJoQ46XLs0",
            "email": "jkfhjkh@kjhhkj.com",
            "name": "lkhjhjkhkj",
            "role": "transporter",
            "phoneNumber": "+6281111111112",
            "phoneNumberVerified": true,
            "accountType": "company",
            "avatar": null,
            "status": "suspended",
            "vehiclesCount": 0,
            "vehicles": [],
            "baseInformation": {
                "id": 2264,
                "address": "Jl Jalan",
                "ownerName": "Bambang",
                "city": "Bekasi",
                "postalCode": "11111"
            },
            "bankInformation": null,
            "documentInfo": [],
            "ratingInfo": {
                "average": 0,
                "count": 0
            },
            "representativeInformation": {
                "id": 269,
                "name": "Joko",
                "title": "Judul",
                "email": "apaaja@yopmail.com",
                "phoneNumber": "+6281211111111"
            }
        }
    },
    "extensions": {
        "tracing": {
            "version": 1,
            "startTime": "2019-10-01T04:16:11.199Z",
            "endTime": "2019-10-01T04:16:11.334Z",
            "duration": 134816991,
            "execution": {
                "resolvers": [
                    {
                        "path": [
                            "myProfile"
                        ],
                        "parentType": "Query",
                        "fieldName": "myProfile",
                        "returnType": "TransporterInterface",
                        "startOffset": 2362687,
                        "duration": 132087827
                    },
                    {
                        "path": [
                            "myProfile",
                            "id"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "id",
                        "returnType": "String!",
                        "startOffset": 134506313,
                        "duration": 23704
                    },
                    {
                        "path": [
                            "myProfile",
                            "email"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "email",
                        "returnType": "String!",
                        "startOffset": 134535421,
                        "duration": 7056
                    },
                    {
                        "path": [
                            "myProfile",
                            "name"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "name",
                        "returnType": "String!",
                        "startOffset": 134546832,
                        "duration": 5744
                    },
                    {
                        "path": [
                            "myProfile",
                            "role"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "role",
                        "returnType": "String!",
                        "startOffset": 134556406,
                        "duration": 5282
                    },
                    {
                        "path": [
                            "myProfile",
                            "phoneNumber"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "phoneNumber",
                        "returnType": "String!",
                        "startOffset": 134565692,
                        "duration": 5185
                    },
                    {
                        "path": [
                            "myProfile",
                            "phoneNumberVerified"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "phoneNumberVerified",
                        "returnType": "Boolean!",
                        "startOffset": 134574849,
                        "duration": 4662
                    },
                    {
                        "path": [
                            "myProfile",
                            "accountType"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "accountType",
                        "returnType": "String!",
                        "startOffset": 134583396,
                        "duration": 4489
                    },
                    {
                        "path": [
                            "myProfile",
                            "avatar"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "avatar",
                        "returnType": "ImageUrls",
                        "startOffset": 134591359,
                        "duration": 8265
                    },
                    {
                        "path": [
                            "myProfile",
                            "status"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "status",
                        "returnType": "TransporterSatus!",
                        "startOffset": 134602997,
                        "duration": 4594
                    },
                    {
                        "path": [
                            "myProfile",
                            "vehiclesCount"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "vehiclesCount",
                        "returnType": "Int!",
                        "startOffset": 134611430,
                        "duration": 4422
                    },
                    {
                        "path": [
                            "myProfile",
                            "vehicles"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "vehicles",
                        "returnType": "[VehicleInterface]!",
                        "startOffset": 134619407,
                        "duration": 7393
                    },
                    {
                        "path": [
                            "myProfile",
                            "baseInformation"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "baseInformation",
                        "returnType": "BaseInformation",
                        "startOffset": 134631794,
                        "duration": 5932
                    },
                    {
                        "path": [
                            "myProfile",
                            "baseInformation",
                            "id"
                        ],
                        "parentType": "BaseInformation",
                        "fieldName": "id",
                        "returnType": "Int!",
                        "startOffset": 134651954,
                        "duration": 6100
                    },
                    {
                        "path": [
                            "myProfile",
                            "baseInformation",
                            "address"
                        ],
                        "parentType": "BaseInformation",
                        "fieldName": "address",
                        "returnType": "String!",
                        "startOffset": 134663227,
                        "duration": 4906
                    },
                    {
                        "path": [
                            "myProfile",
                            "baseInformation",
                            "ownerName"
                        ],
                        "parentType": "BaseInformation",
                        "fieldName": "ownerName",
                        "returnType": "String!",
                        "startOffset": 134671716,
                        "duration": 4506
                    },
                    {
                        "path": [
                            "myProfile",
                            "baseInformation",
                            "city"
                        ],
                        "parentType": "BaseInformation",
                        "fieldName": "city",
                        "returnType": "String!",
                        "startOffset": 134679556,
                        "duration": 4506
                    },
                    {
                        "path": [
                            "myProfile",
                            "baseInformation",
                            "postalCode"
                        ],
                        "parentType": "BaseInformation",
                        "fieldName": "postalCode",
                        "returnType": "String!",
                        "startOffset": 134687650,
                        "duration": 4511
                    },
                    {
                        "path": [
                            "myProfile",
                            "bankInformation"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "bankInformation",
                        "returnType": "BankInformation",
                        "startOffset": 134696232,
                        "duration": 6849
                    },
                    {
                        "path": [
                            "myProfile",
                            "documentInfo"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "documentInfo",
                        "returnType": "[TransporterDocument]",
                        "startOffset": 134706245,
                        "duration": 5061
                    },
                    {
                        "path": [
                            "myProfile",
                            "ratingInfo"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "ratingInfo",
                        "returnType": "RatingInfo!",
                        "startOffset": 134716087,
                        "duration": 5466
                    },
                    {
                        "path": [
                            "myProfile",
                            "ratingInfo",
                            "average"
                        ],
                        "parentType": "RatingInfo",
                        "fieldName": "average",
                        "returnType": "Float!",
                        "startOffset": 134730090,
                        "duration": 5059
                    },
                    {
                        "path": [
                            "myProfile",
                            "ratingInfo",
                            "count"
                        ],
                        "parentType": "RatingInfo",
                        "fieldName": "count",
                        "returnType": "Int!",
                        "startOffset": 134738541,
                        "duration": 4366
                    },
                    {
                        "path": [
                            "myProfile",
                            "representativeInformation"
                        ],
                        "parentType": "CompanyTransporter",
                        "fieldName": "representativeInformation",
                        "returnType": "RepresentativeInformation",
                        "startOffset": 134746434,
                        "duration": 5311
                    },
                    {
                        "path": [
                            "myProfile",
                            "representativeInformation",
                            "id"
                        ],
                        "parentType": "RepresentativeInformation",
                        "fieldName": "id",
                        "returnType": "Int!",
                        "startOffset": 134764092,
                        "duration": 5478
                    },
                    {
                        "path": [
                            "myProfile",
                            "representativeInformation",
                            "name"
                        ],
                        "parentType": "RepresentativeInformation",
                        "fieldName": "name",
                        "returnType": "String!",
                        "startOffset": 134774202,
                        "duration": 4614
                    },
                    {
                        "path": [
                            "myProfile",
                            "representativeInformation",
                            "title"
                        ],
                        "parentType": "RepresentativeInformation",
                        "fieldName": "title",
                        "returnType": "String!",
                        "startOffset": 134782171,
                        "duration": 4365
                    },
                    {
                        "path": [
                            "myProfile",
                            "representativeInformation",
                            "email"
                        ],
                        "parentType": "RepresentativeInformation",
                        "fieldName": "email",
                        "returnType": "String!",
                        "startOffset": 134789734,
                        "duration": 4251
                    },
                    {
                        "path": [
                            "myProfile",
                            "representativeInformation",
                            "phoneNumber"
                        ],
                        "parentType": "RepresentativeInformation",
                        "fieldName": "phoneNumber",
                        "returnType": "String!",
                        "startOffset": 134797242,
                        "duration": 4359
                    }
                ]
            }
        }
    }
}

正如您在上面的响应中看到的那样,我不想在我的graphql请求中存在很多扩展。我的问题是,我怎么才能只通过只包含扩展名的响应来检索结果呢?

1 个答案:

答案 0 :(得分:0)

已为您的项目启用https://github.com/sikanhe/apollo-tracing-elixir。这会将扩展添加到响应中。

有关如何按每个管道禁用它的信息,请参见https://github.com/sikanhe/apollo-tracing-elixir/issues/11。应该不难在运行时基于http标头启用/禁用它。