mlipscombe/postgraphile-plugin-nested-mutations

Cannot read property 'keyAttributeNums' of undefined when creating rows on table with inheritance

Munksgaard opened this issue · 2 comments

I have the following schema:

create schema test;

create table test.user (
  id SERIAL PRIMARY KEY,
  name TEXT NOT NULL
);

create table test.file (
  id SERIAL PRIMARY KEY,
  filename TEXT NOT NULL
);

create table test.user_file (
  user_id INTEGER NOT NULL REFERENCES test.user(id)
) inherits (test.file);

When running postgraphile with postgraphile-plugin-nested-mutations appended, I get this graphql schema.

I then try to run a query through graphiql:

mutation {
  createUser(input: {user: {name: "Philip", userFilesUsingId: {create: [{filename: "foo.txt"}]}}}) {
    user {
      id
      name
      userFilesByUserId {
        nodes {
          id
          filename
        }
      }
    }
  }
}

But I get the following result:

{
  "errors": [
    {
      "message": "Cannot read property 'keyAttributeNums' of undefined",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "createUser"
      ]
    }
  ],
  "data": {
    "createUser": null
  }
}

Hmm, perhaps this is a bug in postgraphile. The following query returns a similar error:

mutation {
  createUserFile(input: {userFile: {filename: "foo.txt", userId: 1}}) {
    userFile {id filename userByUserId{id name}}
  }
}

Ah, I see that it's not supported at all. Closing in favor of graphile/crystal#387