Ejemplo n.º 1
0
 @Override
 public GraphQLObjectType getType() {
   return newObject()
       .name(PROPERTY)
       // Type
       .field(
           newFieldDefinition()
               .name("type")
               .description("Property type")
               .type(propertyType.getType())
               .dataFetcher(GraphqlUtils.fetcher(Property.class, Property::getTypeDescriptor))
               .build())
       // Value
       .field(
           newFieldDefinition()
               .name("value")
               .description("JSON representation of the value")
               .type(GQLScalarJSON.INSTANCE)
               .dataFetcher(GraphqlUtils.fetcher(Property.class, this::getValue))
               .build())
       // Editable
       .field(
           newFieldDefinition()
               .name("editable")
               .description("True is the field is editable")
               .type(GraphQLBoolean)
               .dataFetcher(GraphqlUtils.fetcher(Property.class, Property::isEditable))
               .build())
       // OK
       .build();
 }
 private DataFetcher projectAuthorizationsFetcher() {
   return fetcher(
       Project.class,
       (environment, project) ->
           rolesService
               .getProjectRoles()
               .stream()
               .filter(
                   GraphqlUtils.getStringArgument(environment, "role")
                       .map(s -> (Predicate<ProjectRole>) pr -> StringUtils.equals(s, pr.getId()))
                       .orElseGet(() -> pr -> true))
               .map(projectRole -> getProjectAuthorizations(project, projectRole))
               .collect(Collectors.toList()));
 }