Azure / data-api-builder

Data API builder provides modern REST and GraphQL endpoints to your Azure Databases and on-prem stores.
https://aka.ms/dab/docs
MIT License
956 stars 198 forks source link

Multiple mutations not supported in PGSQL #2485

Open osamamaruf opened 2 days ago

osamamaruf commented 2 days ago

What happened?

Current behavior I am using the following tutorial and while using the following query

mutation {
  createBook(
    item: {
      id: 1
      title: "Introduction to Data API builder"
      pages: 200
      years: 2024
      chapters: [
        {
            id: 2
            name: "Configuration files", pages: 150 
        }
        {
            id: 3
            name: "Running", pages: 50
        }
      ]
    }
  ) {
    id
    title
    pages
    years
    chapters {
      items {
        name
        pages
      }
    }
  }
}

I get the following error;

{
  "errors": [
    {
      "message": "The specified input object field `chapters` does not exist.",
      "locations": [
        {
          "line": 8,
          "column": 7
        }
      ],
      "path": [
        "createBook"
      ],
      "extensions": {
        "field": "chapters",
        "specifiedBy": "http://spec.graphql.org/October2021/#sec-Input-Object-Field-Names"
      }
    }
  ]
}

dab-config.json

{
  "$schema": "https://github.com/Azure/data-api-builder/releases/download/v1.3.19/dab.draft.schema.json",
  "data-source": {
    "database-type": "postgresql",
    "connection-string": "Host=localhost;Port=5431;Database=postgres;User ID=postgres;Password=password;",
    "options": {}
  },
  "runtime": {
    "rest": {
      "enabled": true,
      "path": "/api",
      "request-body-strict": true
    },
    "graphql": {
      "enabled": true,
      "path": "/graphql",
      "allow-introspection": true
    },
    "host": {
      "cors": {
        "origins": [],
        "allow-credentials": false
      },
      "authentication": {
        "provider": "StaticWebApps"
      },
      "mode": "development"
    }
  },
  "entities": {
    "Book": {
      "source": {
        "object": "books",
        "type": "table"
      },
      "graphql": {
        "enabled": true,
        "type": {
          "singular": "Book",
          "plural": "Books"
        }
      },
      "rest": {
        "enabled": true
      },
      "permissions": [
        {
          "role": "anonymous",
          "actions": [
            {
              "action": "*"
            }
          ]
        }
      ],
      "relationships": {
        "chapters": {
          "cardinality": "many",
          "target.entity": "Chapter",
          "source.fields": [],
          "target.fields": [],
          "linking.source.fields": [],
          "linking.target.fields": []
        }
      }
    },
    "Chapter": {
      "source": {
        "object": "chapters",
        "type": "table"
      },
      "graphql": {
        "enabled": true,
        "type": {
          "singular": "Chapter",
          "plural": "Chapters"
        }
      },
      "rest": {
        "enabled": true
      },
      "permissions": [
        {
          "role": "anonymous",
          "actions": [
            {
              "action": "*"
            }
          ]
        }
      ],
      "relationships": {
        "book": {
          "cardinality": "one",
          "target.entity": "Book",
          "source.fields": [],
          "target.fields": [],
          "linking.source.fields": [],
          "linking.target.fields": []
        }
      }
    }
  }
}

Expected Behavior Book and its Chapters should get created.

Version

1.3.19

What database are you using?

PostgreSQL

What hosting model are you using?

Local (including CLI)

Which API approach are you accessing DAB through?

GraphQL

Relevant log output

{
  "errors": [
    {
      "message": "The specified input object field `chapters` does not exist.",
      "locations": [
        {
          "line": 8,
          "column": 7
        }
      ],
      "path": [
        "createBook"
      ],
      "extensions": {
        "field": "chapters",
        "specifiedBy": "http://spec.graphql.org/October2021/#sec-Input-Object-Field-Names"
      }
    }
  ]
}

Code of Conduct

abhishekkumams commented 1 day ago

@osamamaruf , currently multiple mutation is only supported in MSSQL.