Postgraphile: Rename domain to `ID`

Created on 30 Jul 2019  ·  5Comments  ·  Source: graphile/postgraphile

I'm submitting a ...

  • [ ] bug report
  • [ ] feature request
  • [x] question

PostGraphile version:
4.4.2-rc.0

I have a domain that should be renamed to the GraphQL ID type. I tried the following, but the resulting GraphQL type is Id instead of ID:

CREATE DOMAIN my_domain AS TEXT;
COMMENT ON DOMAIN my_domain IS E'@name ID';

Is this expected behaviour or a bug? If this is expected, what would be the way to have a custom domain map to ID?

❔ question

All 5 comments

Question 1: yes, that's expected, the @name still goes through the inflector, which CamelCases it.

Question 2: you'll need a plugin to do that, e.g. this plugin takes all numeric types (id=1700) and uses GraphQLFloat for them:

https://www.graphile.org/postgraphile/plugin-gallery/#Types__PgNumericToFloatPlugin

Yours will need to look up the domain instead; you can find a domain through introspection:

   const htmlDomain = pgIntrospectionResultsByKind.type.find(
      type =>
        type.name === "html" &&
        type.namespaceName ===
          "public"
    );

taken from https://www.graphile.org/postgraphile/plugin-gallery/#Customisation__SanitizeHTMLTypePlugin

[semi-automated message] Thanks for your question; hopefully we're well on the way to helping you solve your issue. This doesn't currently seem to be a bug in the library so I'm going to close the issue, but please feel free to keep requesting help below and if it does turn out to be a bug we can definitely re-open it 👍

You can also ask for help in the #help-and-support channel in our Discord chat.

Ah, this is interesting. In that case I find the documentation about inflection misleading. I interpreted that smart comment renaming doesn't go through inflection.

You're right; that is misleading.

Was this page helpful?
0 / 5 - 0 ratings