Uploaded image for project: 'Causeway'
  1. Causeway
  2. CAUSEWAY-3752

Provide SPI to describe which classes are surfaced by the different viewers.

    XMLWordPrintableJSON

Details

    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.
       
      The proposal is to introduce this SPI:
       

      enum ViewerType {
        WICKET,
        REST,
        GRAPHQL
      }
      public interface ViewerFilterSpi {
          /**
           * the classes to be 
           */
          Optional<List<Class<?>>> include(ViewerType);
       
          Optional<List<Class<?>>> exclude(ViewerType);
      } 

       
      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

       

      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();
          }
        }
      } 

       

      Attachments

        Activity

          People

            danhaywood Daniel Keir Haywood
            danhaywood Daniel Keir Haywood
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: