Browse Source

feat: add query parameter while calling gql api from form view

re #608

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/628/head
Pranav C 3 years ago
parent
commit
46adf6b973
  1. 13
      packages/nc-gui/plugins/ncApis/gqlApi.js

13
packages/nc-gui/plugins/ncApis/gqlApi.js

@ -29,11 +29,14 @@ export default class GqlApi {
return data.data.data[this.gqlQueryCountName] return data.data.data[this.gqlQueryCountName]
} }
post(url, params) { post(url, data, {
params = {}
} = {}) {
return this.$axios({ return this.$axios({
url: `${url}`, url: `${url}`,
method: 'post', method: 'post',
data: params data,
params
}) })
} }
@ -195,15 +198,15 @@ export default class GqlApi {
return data1.data.data[this.gqlMutationUpdateName] return data1.data.data[this.gqlMutationUpdateName]
} }
async insert(data, params = {}) { async insert(data, params) {
const data1 = await this.post(`/nc/${this.$ctx.projectId}/v1/graphql`, { const data1 = await this.post(`/nc/${this.$ctx.projectId}/v1/graphql`, {
query: `mutation create($data:${this.tableCamelized}Input){ query: `mutation create($data:${this.tableCamelized}Input){
${this.gqlMutationCreateName}(data: $data){${this.gqlReqBody}${await this.gqlRelationReqBody(params)}} ${this.gqlMutationCreateName}(data: $data){${this.gqlReqBody}${await this.gqlRelationReqBody({})}}
}`, }`,
variables: { variables: {
data data
} }
}) }, params)
return data1.data.data[this.gqlMutationCreateName] return data1.data.data[this.gqlMutationCreateName]
} }

Loading…
Cancel
Save