(url string)
| 1313 | } |
| 1314 | |
| 1315 | func hasCurrentGraphQLSchema(url string) (bool, error) { |
| 1316 | |
| 1317 | schemaQry := &GraphQLParams{ |
| 1318 | Query: `query { getGQLSchema { schema } }`, |
| 1319 | } |
| 1320 | req, err := schemaQry.CreateGQLPost(url) |
| 1321 | if err != nil { |
| 1322 | return false, errors.Wrap(err, "while creating gql post") |
| 1323 | } |
| 1324 | |
| 1325 | res, err := RunGQLRequest(req) |
| 1326 | if err != nil { |
| 1327 | return false, errors.Wrap(err, "error running GraphQL query") |
| 1328 | } |
| 1329 | |
| 1330 | var result *GraphQLResponse |
| 1331 | err = json.Unmarshal(res, &result) |
| 1332 | if err != nil { |
| 1333 | return false, errors.Wrap(err, "error unmarshalling result") |
| 1334 | } |
| 1335 | |
| 1336 | if len(result.Errors) > 0 { |
| 1337 | return false, result.Errors |
| 1338 | } |
| 1339 | |
| 1340 | var sch struct { |
| 1341 | GetGQLSchema struct { |
| 1342 | Schema string |
| 1343 | } |
| 1344 | } |
| 1345 | |
| 1346 | err = json.Unmarshal(result.Data, &sch) |
| 1347 | if err != nil { |
| 1348 | return false, errors.Wrap(err, "error trying to unmarshal GraphQL query result") |
| 1349 | } |
| 1350 | |
| 1351 | if sch.GetGQLSchema.Schema == "" { |
| 1352 | return false, nil |
| 1353 | } |
| 1354 | |
| 1355 | return true, nil |
| 1356 | } |
| 1357 | |
| 1358 | func addSchema(url, schema string) error { |
| 1359 | add := &GraphQLParams{ |
no test coverage detected