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

customising graphql typename generation per source #6974

Closed
0x777 opened this issue May 24, 2021 · 6 comments
Closed

customising graphql typename generation per source #6974

0x777 opened this issue May 24, 2021 · 6 comments
Assignees

Comments

@0x777
Copy link
Member

0x777 commented May 24, 2021

Currently a source's name is not used in the GraphQL types that we generate. So if two sources have same table names, they can't both be tracked because of type and field conflicts. One can work around this to some extent by customizing each of the table names that cause the conflict. However, it would be very convenient to have this configured per source. We add customization field to the *_add_source API with the following spec:

customization:
  # if root_fields.namespace is absent, the fields
  # are merged into the query root directly
  root_fields:
    namespace: "something"
    prefix: some_prefix
    suffix: some_suffix
  type_names:
    prefix: some_prefix
    suffix: some_suffix
@motleydev
Copy link
Contributor

Another vote for this feature, or more largely described as namespacing sources. Multiple sources is a key part of the Hasura story and adding a configurable guard for field collisions would be useful!

@0x777
Copy link
Member Author

0x777 commented Aug 6, 2021

@dmoverton A source offers some schema customization options under configuration section (custom_name, custom_field_names etc), so let's add these fields to configuration section instead of creating a new customization section.

@dmoverton
Copy link
Contributor

@dmoverton A source offers some schema customization options under configuration section (custom_name, custom_field_names etc), so let's add these fields to configuration section instead of creating a new customization section.

@0x777 the *_add_source APIs don't currently have any customization options. The options you mention are only available for an individual table when calling *_track_table. The configuration section in *_add_table is backend-specific, i.e. the structure is different for Postgres, MSSQL Server, etc. The new customization options don't need to be backend-specific which is why I put them in a new section. This is what makes sense in the code. However, if you think it makes more sense in the API to have these under configuration I can do that.

@0x777
Copy link
Member Author

0x777 commented Aug 16, 2021

The options you mention are only available for an individual table when calling *_track_table

Ah, right. Sorry, my bad. You can ignore my previous message.

@plcplc
Copy link
Contributor

plcplc commented Nov 2, 2021

Closing this issue, as the PR has been merged.

@cleivson
Copy link

cleivson commented Sep 1, 2022

Closing this issue, as the PR has been merged.

What was the PR that solved this issue? Could you point to the version it was released? Thanks

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

5 participants