Skip to content
Elide is a Java library that lets you stand up a GraphQL/JSON-API web service with minimal effort.
Java Other
  1. Java 99.7%
  2. Other 0.3%
Branch: master
Clone or download

Latest commit

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Add license info to pr template (#839) May 24, 2019
elide-annotations [maven-release-plugin] prepare for next development iteration May 26, 2020
elide-contrib [maven-release-plugin] prepare for next development iteration May 26, 2020
elide-core [maven-release-plugin] prepare for next development iteration May 26, 2020
elide-datastore [maven-release-plugin] prepare for next development iteration May 26, 2020
elide-example-models [maven-release-plugin] prepare for next development iteration May 26, 2020
elide-example [maven-release-plugin] prepare for next development iteration May 26, 2020
elide-graphql [maven-release-plugin] prepare for next development iteration May 26, 2020
elide-integration-tests [maven-release-plugin] prepare for next development iteration May 26, 2020
elide-spring [maven-release-plugin] prepare for next development iteration May 26, 2020
elide-standalone [maven-release-plugin] prepare for next development iteration May 26, 2020
translations/zh Update top level README translations (#797) May 2, 2019
travis Added more paths to generated output Jan 4, 2017
.codacy.yml Started skeleton for graphql support Aug 30, 2017
.gitignore Honor ApiModelProperty annotations for relationships (#1180) Feb 6, 2020
.travis.yml Fixing travis to skip tests but still compile them. Jan 18, 2020
CONTRIBUTING.md Add Eclipse import order (#1327) May 18, 2020
Code-Of-Conduct.md Happy path docs (#792) Apr 25, 2019
LICENSE.txt Initial commit. Oct 13, 2015
Makefile Initial commit. Oct 13, 2015
Procfile Add heroku archetype project (#966) Sep 16, 2019
README.md Added awesome badges for Java & GraphQL (#1045) Oct 28, 2019
app.json Add heroku archetype project (#966) Sep 16, 2019
changelog.md Update changelog.md May 26, 2020
checkstyle-style.xml Use isEmpty utilitity (#1182) Feb 11, 2020
checkstyle-suppressions.xml Refactor IT Tests (ResourceIT and test infrastructure). (#897) Sep 3, 2019
elide-eclipse.importorder Add Eclipse import order (#1327) May 18, 2020
elide-intellij-codestyle.xml Organize imports Oct 17, 2018
elide-logo.svg Happy path docs (#792) Apr 25, 2019
graphql-elide.md Started skeleton for graphql support Aug 30, 2017
java.header Add elide spring boot autoconfigure module (#1070) Nov 15, 2019
pom.xml [maven-release-plugin] prepare for next development iteration May 26, 2020
suppressions.xml Fixing Invalid CVE Build Error (The wrong package is being flagged) (#… May 15, 2020
xml.header Add elide spring boot autoconfigure module (#1070) Nov 15, 2019

README.md

Elide

Opinionated APIs for web & mobile applications.

Elide Logo

Spectrum Build Status Maven Central Coverage Status Code Quality: Java Total Alerts Mentioned in Awesome Java Mentioned in Awesome GraphQL

Read this in other languages: 中文.

Table of Contents

Background

Elide is a Java library that lets you set up a GraphQL or JSON API web service with minimal effort starting from a JPA annotated data model.

Elide supports a number of features:

Security Comes Standard

Control access to fields and entities through a declarative, intuitive permission syntax.

Mobile Friendly APIs

JSON-API & GraphQL lets developers fetch entire object graphs in a single round trip. Only requested elements of the data model are returned. Our opinionated approach for mutations addresses common application scenarios:

  • Create a new object and add it to an existing collection in the same operation.
  • Create a set of related, composite objects (a subgraph) and connect it to an existing, persisted graph.
  • Differentiate between deleting an object vs disassociating an object from a relationship (but not deleting it).
  • Change the composition of a relationship to something different.
  • Reference a newly created object inside other mutation operations.

Filtering, sorting, and pagination are supported out of the box.

Atomicity For Complex Writes

Elide supports multiple data model mutations in a single request in either JSON-API or GraphQL. Create objects, add them to relationships, modify or delete together in a single atomic request.

Persistence Layer Agnostic

Elide is agnostic to your particular persistence strategy. Use an ORM or provide your own implementation of a data store.

Schema Introspection

Explore, understand, and compose queries against your Elide API through generated Swagger documentation or GraphQL schema.

Customize

Customize the behavior of data model operations with computed attributes, data validation annotations, and request lifecycle hooks.

Documentation

More information about Elide can be found at elide.io.

Tutorials

Create a JSON API REST Service With Spring Boot and Elide

Custom Security With a Spring Boot/Elide Json API Server

Logging Into a Spring Boot/Elide JSON API Server

Securing a JSON API REST Service With Spring Boot and Elide

Creating Entities in a Spring Boot/Elide JSON API Server

Updating and Deleting with a Spring Boot/Elide JSON API Server

Install

To try out an Elide example service (with a Postgres database), you can deploy via Heroku.

Deploy

The code that generates this example can be found here

Alternatively, use elide-standalone which allows you to quickly setup a local instance of Elide running inside an embedded Jetty application.

Usage

To use Elide, create a set of JPA annotated data models that represent the domain model of your web service:

@Entity
public class Book {

    @Id
    private Integer id;

    private String title;

    @ManyToMany(mappedBy = "books")
    private Set<Author> authors;
}

Add Elide annotations to both expose your models through the web service and define security policies for access:

@Entity
@Include(rootLevel = true)
@ReadPermission("Everyone")
@CreatePermission("Admin OR Publisher")
@DeletePermission("Noone"
@UpdatePermission("Noone")
public class Book {

    @Id
    private Integer id;

    @UpdatePermission("Admin OR Publisher")
    private String title;

    @ManyToMany(mappedBy = "books")
    private Set<Author> authors;
}

Add Lifecycle hooks to your models to embed custom business logic that execute inline with CRUD operations through the web service:

@Entity
@Include(rootLevel = true)
@ReadPermission("Everyone")
@CreatePermission("Admin OR Publisher")
@DeletePermission("Noone")
@UpdatePermission("Noone")
public class Book {

    @Id
    private Integer id;

    @UpdatePermission("Admin OR Publisher")
    private String title;

    @ManyToMany(mappedBy = "books")
    private Set<Author> authors;

    @OnCreatePreCommit
    public void onCreate(RequestScope scope) {
       //Do something
    }
}

Map expressions to security functions or predicates that get pushed to the persistence layer:

    public static class IsAdminUser extends UserCheck {
        @Override
        public boolean ok(User user) {
            return isUserInRole(user, UserRole.admin);
        }
    }

To expose these models, follow the steps documented in elide-standalone:

public class YourMain {
  public static void main(String[] args) {

    ElideStandaloneSettings settings = new ElideStandaloneSettings() {

        @Override
        public String getModelPackageName() {
            //This needs to be changed to the package where your models live.
            return "your.model.package";
        }

        @Override
        public Map<String, Class<? extends Check>> getCheckMappings() {
            //Maps expression clauses to your security check functions & predicates
            return new HashMap<String, Class<? extends Check>>() { {
                put("Admin", IsAdminUser.class);
            }
        };
    });

    ElideStandalone elide = new ElideStandalone(settings);

    elide.start();
  }
}

For example API calls, look at:

  1. JSON-API
  2. GraphQL

Security

Security is documented in depth here.

Contribute

Please refer to the contributing.md file for information about how to get involved. We welcome issues, questions, and pull requests.

If you are contributing to Elide using an IDE, such as IntelliJ, make sure to install the Lombok plugin.

Discussion is on spectrum or through filing issues.

License

This project is licensed under the terms of the Apache 2.0 open source license. Please refer to LICENSE for the full terms.

You can’t perform that action at this time.