Search code examples
postgraphile

Is there a way to replace a generated endpoint in Postgraphile?


I have a Postgraphile-using database with a foo table. Recently I moved the columns of that table into a bar table.

In other words, before I had:

Foos:
{ id: 1, title: 'Bob' }

But now I have:

Foos:
{ id: 1, bar_id: 2 }

Bars:
{ id: 2, title: 'Bob' }

In postgraphile, this means my queries have changed from:

foo { title }

to:

foo { bar { title } }

I'd like to somehow replace the foo endpoint in my API, so that I can once again allow queries like:

foo { title }

How can I do this?

If I try to use the makeExtendSchemaPlugin and define my own foo endpoint, I get an error saying that I have two definitions for the same foo endpoint.

Is there some way to make new endpoint "trump" the generated one, either by using that plugin, or by using a different one?


Solution

  • Is there some way to make new endpoint "trump" the generated one?

    No. You cannot have two plugins/hooks generate the same field, it will always throw an error. There is no way to make one "overwrite" the other.

    What you can do is