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

"routers" parameter for queries #88

Open
gsteel opened this issue Jan 7, 2022 · 2 comments · Fixed by #91
Open

"routers" parameter for queries #88

gsteel opened this issue Jan 7, 2022 · 2 comments · Fixed by #91
Labels
enhancement New feature or request
Milestone

Comments

@gsteel
Copy link
Member

gsteel commented Jan 7, 2022

Apparently, you can provide a routers query parameter to the API and it will "resolve" urls for documents and links with this information on the server returning the urls in the payload.

This means that all types would possibly contain a top-level url property and url may also be present in links that have Document type.

The documentation is pretty scant:

… but it looks like you can provide router config during initialisation and then reuse the config for every request thereafter. I assume that the config will be included in the meta-data payload as default options for the forms property.

Currently, it looks like routers should be specified as a JSON array of objects, something like this:

let routers = [
    {
        "type": "my-type", // Name of document type
        "path": "/products/:range/:category/:uid", // Where ":category" is the UID of the linked category document and ":range" is the UID of the grandparent category.range document
        "resolvers": {
            "category": "parent-category", // Top-level content relationship to a "category" type where "parent-category" is the property name of "my-type"
            "range": "category.range" // "range" is a property of "category" in this example being a content-relationship to a range document.
        }
    },
    {
        "type": "blog-post",
        "path": "/:lang/blog/:uid" // :lang is the document locale ie 'en-gb'
    },
    // Not yet known whether other types/properties are feasible such as
    {
        "type": "whatever",
        "path": "/:id/:date-published/:tags" // <- Who knows?
    }
];
@gsteel gsteel added the enhancement New feature or request label Jan 7, 2022
@gsteel
Copy link
Member Author

gsteel commented Jan 7, 2022

Result sets over multiple pages from queries where the routes parameter has been provided do not include the route configuration in the URLs for the next and previous pages. This makes those URLs effectively useless.

@gsteel
Copy link
Member Author

gsteel commented Jan 7, 2022

Generic document properties that definitely do not work as route url parameters:

  • type
  • id
  • date
  • href
  • first_publication_date
  • last_publication_date

It looks like only lang and uid are supported on the root document, and only uid on linked documents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant