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

Support dynamic identifier field names/paths for content entries #10

Open
tonyketcham opened this issue Nov 27, 2021 · 3 comments · May be fixed by #84
Open

Support dynamic identifier field names/paths for content entries #10

tonyketcham opened this issue Nov 27, 2021 · 3 comments · May be fixed by #84
Labels
config User config core central engine enhancement New feature or request good first issue Good for newcomers gql-schema Pertains to GraphQL schema design/implementation
Milestone

Comments

@tonyketcham
Copy link
Collaborator

Currently, Flatbread expects there to be an id field in the root level of each entry type in order to enable relations and query by ID. Some people may have related data using a slug field to identify content entries, or even a nested field within each entry like meta: {id: 'EFJS-34UID'}.

In flatbread.config.js, the user should be able to define the path to their identifier field for each content type if it does not match the default behavior of Flatbread as stated above. Some sugar on top of that may be a root level config option to globally change the identifier name for all content entries, like if all entries are related by a slug or uuid field rather than id, for example.

@tonyketcham tonyketcham added enhancement New feature or request good first issue Good for newcomers gql-schema Pertains to GraphQL schema design/implementation config User config core central engine labels Nov 27, 2021
@tonyketcham tonyketcham changed the title Support dynamic type ID fields Support dynamic identifier field names/paths for content entries Nov 27, 2021
@tonyketcham tonyketcham added this to the v1.0 🌿 milestone Jul 22, 2022
@odama626
Copy link
Collaborator

odama626 commented Aug 3, 2022

Maybe we could optionally specify a primary key on the content block in the config?

@tonyketcham
Copy link
Collaborator Author

Yeah that's what I was thinking:

// this one feels real good to me but is a bit SQL-biased in terminology
{
  path: 'content/markdown/posts',
  collection: 'Post',
  primaryKey: 'meta.id',
  refs: {
    authors: 'Author',
  },
},

// perhaps a bit more friendly sounding
{
  path: 'content/markdown/posts',
  collection: 'Post',
  idField: 'meta.id',
  refs: {
    authors: 'Author',
  },
},

// or
{
  path: 'content/markdown/posts',
  collection: 'Post',
  identifier: 'meta.id',
  refs: {
    authors: 'Author',
  },
},

@tonyketcham
Copy link
Collaborator Author

Actually yeah I think I like primaryKey the most since it's ubiquitous in relational data

@odama626 odama626 linked a pull request Aug 16, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config User config core central engine enhancement New feature or request good first issue Good for newcomers gql-schema Pertains to GraphQL schema design/implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants