Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
chunkai1312 committed Aug 29, 2016
2 parents 8d53f37 + eaf3a03 commit 3e982a7
Show file tree
Hide file tree
Showing 19 changed files with 1,756 additions and 1,153 deletions.
6 changes: 3 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"presets": ["es2015-loose"],
"plugins": ["transform-es2015-modules-umd"]
}
"presets": ["es2015"],
"plugins": ["add-module-exports"]
}
10 changes: 2 additions & 8 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,5 @@
"node": true,
"mocha": true
},
"extends": "airbnb-base",
"rules": {
"no-console": 0,
"no-underscore-dangle": 0,
"max-len": 0,
"no-unused-expressions": 0
}
}
"extends": "standard"
}
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# fqb changelog

## 1.1.0 / 2016-08-29

- Refactor and use [JavaScript Standard Style](http://standardjs.com/)
- Add index.js in root as entry point
- Use [babel-plugin-add-module-exports](https://github.com/59naga/babel-plugin-add-module-exports) to always export a default to exports.default
- Modify NPM scripts for build tasks
- Update dependencies version

## 1.0.1 / 2016-06-22

- Fixed module description
- Fix module description

## 1.0.0 / 2016-06-22

- Initial release
- Initial release
34 changes: 18 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

> Facebook Graph API query builder for JavaScript
[![JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)

## Install

```shell
Expand All @@ -21,7 +23,7 @@ Add a `<script>` to your `index.html`:
Import the module to your `*.js` file:

```js
const FQB = require('fqb');
const FQB = require('fqb')
```

## Usage
Expand All @@ -35,12 +37,12 @@ const fqb = new FQB()
.node('me')
.fields(['id', 'email'])
.accessToken('user-access-token')
.graphVersion('v2.6');
.graphVersion('v2.6')

console.log(fqb.asEndpoint());
console.log(fqb.asEndpoint())
// /v2.6/me?access_token=user-access-token&fields=id,email

console.log(fqb.asUrl());
console.log(fqb.asUrl())
// https://graph.facebook.com/v2.6/me?access_token=user-access-token&fields=id,email
```

Expand All @@ -52,43 +54,43 @@ The following example will get the logged in user's name & first 5 photos they a
const photosEdge = new FQB()
.edge('photos')
.fields(['id', 'source'])
.limit(5);
.limit(5)

const fqb = new FQB()
.node('me')
.fields(['name', photosEdge]);
.fields(['name', photosEdge])

console.log(fqb.asEndpoint());
console.log(fqb.asEndpoint())
// /me?fields=name,photos.limit(5){id,source}

console.log(fqb.asUrl());
console.log(fqb.asUrl())
// https://graph.facebook.com/me?fields=name,photos.limit(5){id,source}
```

The following example will get user `1234`'s name, and first 10 photos they are tagged in. For each photo it gets the first 2 comments and all the likes.

```js
const likesEdge = new FQB()
.edge('likes');
.edge('likes')

const commentsEdge = new FQB()
.edge('comments')
.fields('message')
.limit(2);
.limit(2)

const photosEdge = new FQB()
.edge('photos')
.fields(['id', 'source', commentsEdge, likesEdge])
.limit(10);
.limit(10)

const fqb = new FQB()
.node('1234')
.fields(['name', photosEdge]);
.fields(['name', photosEdge])

console.log(fqb.asEndpoint());
console.log(fqb.asEndpoint())
// /1234?fields=name,photos.limit(10){id,source,comments.limit(2){message},likes}

console.log(fqb.asUrl());
console.log(fqb.asUrl())
// https://graph.facebook.com/1234?fields=name,photos.limit(10){id,source,comments.limit(2){message},likes}
```

Expand All @@ -98,7 +100,7 @@ console.log(fqb.asUrl());
$ npm test
```

## Inspiration
## Note

Inspired by [FacebookQueryBuilder](https://github.com/SammyK/FacebookQueryBuilder)

Expand All @@ -110,7 +112,7 @@ Facebook's [Graph API](https://developers.facebook.com/docs/graph-api)

MIT © [Chun-Kai Wang](https://github.com/chunkai1312)

[npm-image]: https://badge.fury.io/js/fqb.svg
[npm-image]: https://img.shields.io/npm/v/fqb.svg
[npm-url]: https://npmjs.org/package/fqb
[travis-image]: https://travis-ci.org/chunkai1312/fqb.svg?branch=master
[travis-url]: https://travis-ci.org/chunkai1312/fqb
Loading

0 comments on commit 3e982a7

Please sign in to comment.