[ 
https://issues.apache.org/jira/browse/CAUSEWAY-3752?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andi Huber updated CAUSEWAY-3752:
---------------------------------
    Description: 
Before releasing 2.0.0/3.0.0, we decided to make 
`@DomainService(nature=VIEW|REST_ONLY)` a no-op , for a couple of reasons:
 * we now have a GraphQL viewer, and the enum didn't seem general enough
 * the REST API has its own rather adhoc mechanism for what to expose: public, 
prototyping or private
 ** but this only affects the Swagger file, not the actual API that's actually 
available
 * the GraphQL viewer has an issue that it takes a loooong time to expose the 
entire API; and probably we wouldn't want to do that.

 In removing `@DomainService(nature=...)`, we told ourselves that users could 
just use security; but that doesn't address the above issues.
 
We propose a new programing model to honor _Viewer_ specific _Domain Object_ 
visibility:

{color:#0f0f0f}Instead of referencing viewer IDs directly, users declare intent 
using {color}*abstract profiles*{color:#0f0f0f} (e.g., 
{color}{{{}web-ui{}}}{color:#0f0f0f}, {color}{{{}api-v2{}}}{color:#0f0f0f}, 
{color}{{{}mobile{}}}{color:#0f0f0f}, {color}{{{}admin{}}}{color:#0f0f0f}). The 
framework maps these profiles to actual viewer IDs via configuration.{color}

Configuration:
{noformat}
# Map viewer IDs to the profiles they support
causeway.viewer-profiles.wicket=web-ui
causeway.viewer-profiles.restful=api,restful-only
causeway.viewer-profiles.qraphql=api,graphql-only

# Global fallback
causeway.viewer-profiles.default=web-ui

# Namespace specific overrides
causeway.viewer-profiles.default.com.myapp.orders=web-ui
causeway.viewer-profiles.default.com.myapp.payments=api
causeway.viewer-profiles.default.com.myapp.reports=web-ui,api
{noformat}
Defaults can then be overridden on a per class basis:
{code:java}
@ObjectLayout(showFor = {"web-ui", "restful-only"}) 
class SomeDomainObject {
}
{code}
(If unspecified, defaults from config apply.)

  was:
Before releasing 2.0.0/3.0.0, we decided to make 
`@DomainService(nature=VIEW|REST_ONLY)` a no-op , for a couple of reasons:
 * we now have a GraphQL viewer, and the enum didn't seem general enough
 * the REST API has its own rather adhoc mechanism for what to expose: public, 
prototyping or private
 ** but this only affects the Swagger file, not the actual API that's actually 
available
 * the GraphQL viewer has an issue that it takes a loooong time to expose the 
entire API; and probably we wouldn't want to do that.

 
In removing `@DomainService(nature=...)`, we told ourselves that users could 
just use security; but that doesn't address the above issues.
 
The proposal is to introduce this SPI:
 
{code:java}
enum ViewerType {
  WICKET,
  REST,
  GRAPHQL
}
public interface ViewerFilterSpi {
    /**
     * the classes to be 
     */
    Optional<List<Class<?>>> include(ViewerType);
 
    Optional<List<Class<?>>> exclude(ViewerType);
} {code}


 
This will be used by the different viewers at different stages:
 * by Wicket viewer - when rendering
 * by REST API - when generating swagger + to prevent calls to anything that's 
not specified...
 * by GraphQL - when building the GraphQL metamodel

 
{code:java}
public class MyAppViewFilter implements ... {
 public Optional<List<Class<?>>> include(...) {
   switch viewerType {
     case WICKET:
       return Optional.empty;
     case REST:
       return Optional.of(Arrays.asList(....));
     case GRAPHQL:
       return Optional.of(Arrays.asList(....));
    }
  }
  public Optional<List<Class>>> exclude(...) {
    switch viewerType {
      case WICKET:
        return include(REST);
      case REST:
        return Optional.empty();
      case GRAPHQL:
        return Optional.empty();
    }
  }
} {code}

 


> Provide SPI to describe which classes are surfaced by the different viewers.
> ----------------------------------------------------------------------------
>
>                 Key: CAUSEWAY-3752
>                 URL: https://issues.apache.org/jira/browse/CAUSEWAY-3752
>             Project: Causeway
>          Issue Type: New Feature
>          Components: Core, Viewer GraphQL, Viewer RO, Viewer Wicket
>    Affects Versions: 2.0.0
>            Reporter: Daniel Keir Haywood
>            Assignee: Andi Huber
>            Priority: Major
>             Fix For: 4.0.0
>
>
> Before releasing 2.0.0/3.0.0, we decided to make 
> `@DomainService(nature=VIEW|REST_ONLY)` a no-op , for a couple of reasons:
>  * we now have a GraphQL viewer, and the enum didn't seem general enough
>  * the REST API has its own rather adhoc mechanism for what to expose: 
> public, prototyping or private
>  ** but this only affects the Swagger file, not the actual API that's 
> actually available
>  * the GraphQL viewer has an issue that it takes a loooong time to expose the 
> entire API; and probably we wouldn't want to do that.
>  In removing `@DomainService(nature=...)`, we told ourselves that users could 
> just use security; but that doesn't address the above issues.
>  
> We propose a new programing model to honor _Viewer_ specific _Domain Object_ 
> visibility:
> {color:#0f0f0f}Instead of referencing viewer IDs directly, users declare 
> intent using {color}*abstract profiles*{color:#0f0f0f} (e.g., 
> {color}{{{}web-ui{}}}{color:#0f0f0f}, {color}{{{}api-v2{}}}{color:#0f0f0f}, 
> {color}{{{}mobile{}}}{color:#0f0f0f}, {color}{{{}admin{}}}{color:#0f0f0f}). 
> The framework maps these profiles to actual viewer IDs via 
> configuration.{color}
> Configuration:
> {noformat}
> # Map viewer IDs to the profiles they support
> causeway.viewer-profiles.wicket=web-ui
> causeway.viewer-profiles.restful=api,restful-only
> causeway.viewer-profiles.qraphql=api,graphql-only
> # Global fallback
> causeway.viewer-profiles.default=web-ui
> # Namespace specific overrides
> causeway.viewer-profiles.default.com.myapp.orders=web-ui
> causeway.viewer-profiles.default.com.myapp.payments=api
> causeway.viewer-profiles.default.com.myapp.reports=web-ui,api
> {noformat}
> Defaults can then be overridden on a per class basis:
> {code:java}
> @ObjectLayout(showFor = {"web-ui", "restful-only"}) 
> class SomeDomainObject {
> }
> {code}
> (If unspecified, defaults from config apply.)



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to