<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=490755098261949&amp;ev=PageView&amp;noscript=1">

:tada:2024 WEBBY WINNER: The Crate & Barrel mobile app won a Webby Award!

GraphQL — Omit table from generating under ‘graphiql’. Postgres smart comments.

Pratik Agashe
Author Pratik Agashe
Published On Jun 16, 2020


Before we start, I would like to give a quick background story behind this post. This is a sub-post of the “Building Full-stack web app with PostGraphile and React”. So I have used related table names.

As we know GraphQL is an open-source data query and manipulation language for APIs, and a runtime for fulfilling queries with existing data.

Graphiql is a graphical interactive in-browser GraphQL IDE. You can see all available queries and mutations based on our schema, which is given to the client.

But what if you want to omit some table from generating their mutations from graphql?

If you are using Postgres then you can add smart comments for particular a table. That will omit or exclude that table from generating its mutation.

There are two ways to add smart comments.


  1. Open `sql shell (psql)`- This is a command line tool for psql. It will ask you which table you want to select. Enter table name: in our case postgres-graphql.
  2. Now run following commands and graphql will remove mutation from auto generated graphiql.

Reference to add Smart Comment from SQL Shell (psql)


  1. Open pgAdmin.
  2. Navigate to your database -> schema (public) -> table list.
  3. Now right click on table knex_migration and select properties
  4. One popup will open. Under comments, add the following lines.


@name knex_migrations
@omit create,update,delete
This is the documentation.

5. Follow the same process for knex_migrations_lock, and paste the following lines.

@name knex_migrations_lock
@omit create,update,delete
This is the documentation.



Reference to add Smart Comment from pgAdmin 4

That’s it!

Now when we reload our graphiql, we’ll find the mutations for these tables are no longer there.



Interested in a career at Heady?

Excellent! We are always looking for great talent.


Interested in a career at Heady?

Excellent! We are always looking for great talent.


Figuring out your next step? We're here for you.

Or drop us a line.