Skip to content

Updating rest methods leads to an update to grapql operations #1554

@severussundar

Description

@severussundar

I want to bring to attention the following scenario which breaks and can be a bug.

  1. Creating a stored procedure entity with graphql configured for Query

Command: dab add getbooks --source "get_books" --source.type "stored-procedure" --permissions "anonymous:execute" --graphql.operation "query"
Config Json (just the entities section):

 "entities": {
    "getbooks": {
  "source": {
    "object": "get_books",
    "type": "stored-procedure",
    "parameters": null,
    "key-fields": null
  },
  "graphql": {
    "enabled": true,
    "operation": "query",
    "type": {
      "singular": "getbooks",
      "plural": "getbooks"
    }
  },
  "rest": {
    "enabled": true,
    "path": null,
    "methods": [
      "post"
    ]
  },
  "permissions": [
    {
      "role": "anonymous",
      "actions": [
        {
          "action": "execute",
          "fields": null,
          "policy": {
            "request": null,
            "database": null
          }
        }
      ]
    }
  ],
  "mappings": null,
  "relationships": null
}
  }
  1. Update the rest method to GET
    Command: dab update getbooks --rest.methods "GET"

Config Json:

"entities": {
    "getbooks": {
  "source": {
    "object": "get_books",
    "type": "stored-procedure",
    "parameters": null,
    "key-fields": null
  },
  "graphql": {
    "enabled": true,
    "operation": "mutation",
    "type": {
      "singular": "getbooks",
      "plural": "getbooks"
    }
  },
  "rest": {
    "enabled": true,
    "path": null,
    "methods": [
      "get"
    ]
  },
  "permissions": [
    {
      "role": "anonymous",
      "actions": [
        {
          "action": "execute",
          "fields": null,
          "policy": {
            "request": null,
            "database": null
          }
        }
      ]
    }
  ],
  "mappings": null,
  "relationships": null
}
  }

When updating the rest.methods, the graphql operation has lost its original value of query. It now has the default value of mutation.

This scenario works fine in the current main branch. Please find below the commands and the config jsons generated using the main branch.

  1. Creating a new stored procedure entity
    Command: dab add getbooks --source "getbooks" --source.type "stored-procedure" --permissions "anonymous:execute" --graphql.operation "query"

Config json:

"entities": {
    "getbooks": {
      "source": {
        "type": "stored-procedure",
        "object": "getbooks"
      },
      "permissions": [
        {
          "role": "anonymous",
          "actions": [
            "execute"
          ]
        }
      ],
      "rest": {
        "methods": [
          "post"
        ]
      },
      "graphql": {
        "operation": "query"
      }
    }
  }
  1. Updating the rest methods
    Command: dab update getbooks --rest.methods "get"
    Config json:
"entities": {
    "getbooks": {
      "source": {
        "type": "stored-procedure",
        "object": "getbooks"
      },
      "permissions": [
        {
          "role": "anonymous",
          "actions": [
            "execute"
          ]
        }
      ],
      "rest": {
        "methods": [
          "get"
        ]
      },
      "graphql": {
        "operation": "query"
      }
    }
  }

The value present in the graphql operation is preserved. Only the rest methods are updated.

Would greatly appreciate if you could take a look at this.

Originally posted by @severussundar in #1402 (comment)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcli

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions