Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding new list causes "GraphQL error: select count(*)" error #3024

Closed
andregoldstein opened this issue May 22, 2020 · 3 comments
Closed

Adding new list causes "GraphQL error: select count(*)" error #3024

andregoldstein opened this issue May 22, 2020 · 3 comments

Comments

@andregoldstein
Copy link

When creating first list on fresh install, receive GraphQL error in admin dashboard

When trying to add my first list on a fresh install using Postgres and the users/auth starter I receive a GraphQL error when logging into admin

GraphQL error: select count(*) from "public"."Clinic" as "t0" where true - relation "public.Clinic" does not exist
GraphQL error: select "t0".* from "public"."Clinic" as "t0" where true order by "name" ASC limit $1 - relation "public.Clinic" does not exist GraphQL error: select count(*) from "public"."Clinic" as "t0" where true and "t0"."name" ~* $1 - relation "public.Clinic" does not exist

To Reproduce

  1. Install with yarn create keystone-app app-name
  2. Choose users/auth starter
  3. Choose Postgres and postgres connection string (connects ok)
  4. Run yarn create-tables
  5. Add the following code to add a Clinic list:
keystone.createList('Clinic', {
  fields: {
    name: { type: Text },
  },
  // List-level access controls
  access: {
    read: access.userIsAdminOrOwner,
    update: access.userIsAdminOrOwner,
    create: access.userIsAdmin,
    delete: access.userIsAdmin,
    auth: true,
  },
})

Expected behaviour

Expected to be able to access this new model in the admin

System information

  • OS: macOS
  • Browser: Chrome
@MadeByMike
Copy link
Contributor

It's likely you need to run yarn create-tables. For the Knex Adapter Keystone will not automatically initialise an SQL database, but there is a command to do this.

You can see the docs on initialising tables here: https://www.keystonejs.com/quick-start/#installing-keystone

@molomby
Copy link
Member

molomby commented Jun 1, 2020

Clarifying @MadeByMike's comment -- the yarn create-tables command creates tables in your DB for the lists currently defined in your Keystone schema. Based on your reproduction steps, it looks like you may have run yarn create-tables (step 4) then added the list to your schema (step 5). Just reverse these two steps!

@andregoldstein
Copy link
Author

Hi @molomby thanks so much for your reply, I will go back to my project and try it this way around, it's possible I hadn't got it the right way around!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants