1.0.5 • Published 7 years ago

modelizr v1.0.5

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

modelizr

Coverage Status Build Status npm version Gitter

A Combination of normalizr, fakerjs and GraphQL that allows you to define multipurpose models that can generate GraphQL queries, mock deeply nested data and normalize

Installation

$ yarn add modelizr

What can I use this for?

  • Easily generating GraphQL queries from models.
  • Flat-mapping responses using normalizr.
  • Mocking deeply nested data that match the structure of a GraphQL query.

Read my medium post on why I wrote modelizr.

What does it look like?

import { Modelizr } from 'modelizr'

const ModelData = {
  Person: {
    normalizeAs: "People",
    fields: {
      id: Number,
      firstName: String,
      Books: ["Book"]
    }
  },
    
  Book: {
    normalizeAs: "Books",
    fields: {
      id: Number,
      title: String,
      Author: "Person"
    }
  }
}

const {query, models: {Person, Book}} = new Modelizr({
  models: ModelData,
  config: {
    endpoint: "http:// ..."
  }
})

query(
  Person({id: 1}
    Book("Books")
  ),
  
  Book("Books", {ids: [4, 5]})
).then((res, normalize) => {
  normalize(res.body) // -> normalized response.
})

This will generate the following query and make a request using it.

{
  Person(id: 1) {
    id,
    firstName,
    Books {
      id,
      title
    }
  },
  
  Books(ids: [4, 5]) {
    id,
    title,
    Author {
      id,
      firstName
    }
  }
}

Documentation

NOTE: Documentation for pre-v1.0.0 can be found Here

All documentation is located at julienvincent.github.io/modelizr

Example

  • $ yarn
  • $ yarn start

navigate to http://localhost:8000 in your browser

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

8 years ago

1.0.0

8 years ago

1.0.0-beta.12

8 years ago

1.0.0-beta.11

8 years ago

1.0.0-beta.10

8 years ago

1.0.0-beta.9

8 years ago

1.0.0-beta.8

8 years ago

1.0.0-beta.7

8 years ago

1.0.0-beta.6

8 years ago

1.0.0-beta.5

8 years ago

1.0.0-beta.4

8 years ago

1.0.0-beta.3

8 years ago

1.0.0-beta.2

8 years ago

1.0.0-beta.1

8 years ago

0.7.10

8 years ago

0.7.9

8 years ago

0.7.8

8 years ago

0.7.7

8 years ago

0.7.6

8 years ago

0.7.5

8 years ago

0.7.4

8 years ago

0.7.3

8 years ago

0.7.2

8 years ago

0.7.1

8 years ago

0.7.0

8 years ago

0.6.1

8 years ago

0.6.0

9 years ago

0.5.1

9 years ago

0.5.0

9 years ago

0.4.14

9 years ago

0.4.13

9 years ago

0.4.12

9 years ago

0.4.11

9 years ago

0.4.10

9 years ago

0.4.9

9 years ago

0.4.8

9 years ago

0.4.7

9 years ago

0.4.6

9 years ago

0.4.5

9 years ago

0.4.4

9 years ago

0.4.3

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.3

9 years ago

0.3.2

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.3.0-rc4

9 years ago

0.3.0-rc3

9 years ago

0.3.0-rc2

9 years ago

0.3.0-rc1

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.7

9 years ago

0.1.6

9 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago