adobe / aem-headless-client-js

AEM Headless Client for JavaScript
Apache License 2.0
25 stars 12 forks source link

Review JavaScript constructor style and method names #12

Closed bdelacretaz closed 3 years ago

bdelacretaz commented 3 years ago

We'd like to review the constructor style and probably move to a ctor(config object) style, and the method names could be more explicit.

This goes together with https://github.com/adobe/aem-headless-client-java/issues/2 which is the same thing for the Java client.

bdelacretaz commented 3 years ago

Constructor Style

For the constructor I suggest

new AEMHeadless(<graphql_endpoint: String>)

As a the minimal version with just the endpoint config (assuming that's useful, without credentials?) and

new AEMHeadless(<config object>)

when the client needs more parameters.

The config object might be

{
    serviceURL: <the URL of the AEM server>,
    credentials: {
        username: ...
        password: ...
    },
    authToken: ...
}

Where either credentials or the authToken are specified.

What do people think?

bdelacretaz commented 3 years ago

Method Names

I suggest the following method names:

* runQuery(stmt) -> executes a query based on a GraphQL query statement
* runPersistedQuery(path) -> executes a persisted query based on its path
* persistQuery(path, stmt) -> saves a persisted query at the given path
* listQueries() -> list all persisted queries. Assuming that's reasonable and the result can be streamed, or there's a limit on how many results are returned.

What do people think?

bdelacretaz commented 3 years ago

Note that the next release should have a major release number as we're changing the API. At this early stage I don't think that's a problem.

gknobloch commented 3 years ago

I'm just wondering if listQueries() should be listPersistedQueries() to align with runPersistedQuery() Besides this, I'm +1

ghenzler commented 3 years ago

Fair enough - let's make it

* runQuery(stmt) -> executes a query based on a GraphQL query statement
* runPersistedQuery(path) -> executes a persisted query based on its path
* persistQuery(path, stmt) -> saves a persisted query at the given path
* listPersistedQueries() -> list all persisted queries

then