ThiagoPXP
ThiagoPXP

Reputation: 5462

is there a way to create Keystone lists in runtime after keystone initialisation?

I'd like to create a KeystoneJs (v5.0.6) during runtime as some lists might be dynamically generated by the user.

If I run the following command after keystone has been intialised, I get the error: "Error: keystone.createList must be called before keystone.prepare()"

keystone.createList("MyDynamicList", {
    fields: {
      name: { type: Text },
      email: {
        type: Text,
        isUnique: true,
      },
    },
  });

Is there a way lists can be generated dynamically during runtime?

Upvotes: 0

Views: 102

Answers (1)

Gautam Singh
Gautam Singh

Reputation: 1138

this is not possible, all the lists (and fields) has to be provided in keystone.createList method. keystone generates all the schema for GraphQL before you run keystone.connect.

There was a PR and request for delaying initialization in case someone wanted to add a field using a plugin before keystone.connect call which was denied.

Based on that discussion it is highly unlikely that this type of request even be priority for long.

Upvotes: 1

Related Questions