Giter VIP home page Giter VIP logo

inquisitor_jsonapi's Introduction

Inquisitor JSONAPI Build Status

Easily build composable queries for Ecto for JSON API endpoints using Inquisitor

Inquisitor JSONAPI is built and maintained by DockYard, contact us for expert Elixir and Phoenix consulting.

This plugin for Inquisitor aims to implement all of the relevant Fetching Data section for the JSON API spec

Make sure you reference Inquisitor's Usage section first

Progress

Include

JSON API Include (Ecto preload) Plugin

Usage

Use Inquisitor.JsonApi.Include after Inquisitor

defmodule MyApp.PostController do
  use MyAp.Web, :controller
  use Inquisitor
  use Inquisitor.JsonApi.Include

  ...

This plugin follows the spec for sorting with JSON API. All requests should conform to that URL schema for this plugin to work.

[GET] http://example.com/posts?include=tags,author

Refer to the Docs for this module on how to enable preloading properly.

Sort

JSON API Sorting Plugin

Usage

Use Inquisitor.JsonApi.Sort after Inquisitor

defmodule MyApp.PostController do
  use MyAp.Web, :controller
  use Inquisitor
  use Inquisitor.JsonApi.Sort

  ...

This plugin follows the spec for sorting with JSON API. All requests should conform to that URL schema for this plugin to work.

[GET] http://example.com/posts?sort=-create,title

The plugin with correct apply ASC and DESC sort order to the built query.

Page

JSON API Pagination Plugin

Usage

Use Inquisitor.JsonApi.Page after Inquisitor

defmodule MyApp.PostController do
  use MyAp.Web, :controller
  use Inquisitor
  use Inquisitor.JsonApi.Page

  ...

This plugin follows the spec for pagination with JSON API. All requests should conform to that URL schema for this plugin to work.

[GET] http://example.com/posts?page[limit]=10&page[offset]=2 [GET] http://example.com/posts?page[size]=10&page[number]=2

Cursor pagination is not yet implemented.

You may need to calculate certain page data to generate pagination links. You can use page_data/3 that this module imports for you.

  query = build_query(User, conn, params)
  data = page_data(query, repo, params)

  links = build_links(data)
  meta = build_meta(data)
  users = Repo.all(query)

Filter

JSON API Filtering Plugin

Usage

Use Inquisitor.JsonApi.Filter after Inquisitor

defmodule MyApp.PostController do
  use MyAp.Web, :controller
  use Inquisitor
  use Inquisitor.JsonApi.Filter

  ...

This plugin follows the spec for pagination with JSON API. All requests should conform to that URL schema for this plugin to work.

[GET] http://example.com/posts?filter[name]=Brian&filter[age]=99

By default Filter is no-op. You must define a custom build_filter_query/4 handler:

def build_filter_query(query, "name", name, _conn) do
  Ecto.Query.where(query, [r], r.name == ^name)
end

Authors

We are very thankful for the many contributors

Versioning

This library follows Semantic Versioning

Want to help?

Please do! We are always looking to improve this library. Please see our Contribution Guidelines on how to properly submit issues and pull requests.

Legal

DockYard, Inc. © 2017

@dockyard

Licensed under the MIT license

inquisitor_jsonapi's People

Contributors

bcardarella avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.