Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "smapper", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"author": "David Arenas (davejs136@gmail.com)", | ||
@@ -5,0 +5,0 @@ "description": "Mapper function to transform the Strapi API response", |
@@ -5,3 +5,2 @@ # Smapper | ||
[![npm downloads][npm-downloads-src]][npm-downloads-href] | ||
[![Codecov][codecov-src]][codecov-href] | ||
[![License][license-src]][license-href] | ||
@@ -41,2 +40,38 @@ | ||
We have a graphql like this: | ||
```graphql | ||
query Posts { | ||
posts { | ||
data { | ||
attributes { | ||
title | ||
content | ||
slug | ||
images { | ||
data { | ||
id | ||
attributes { | ||
name | ||
formats | ||
url | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
And you want remove the data and attributes wrappers, just call the function imported and pass the graphql result as parameter: | ||
```javascript | ||
import mapper from 'smapper'; | ||
import GetPost from './graphql'; | ||
const response = await graphql(GetPost); | ||
const mapped = mapper(response); | ||
``` | ||
## Development | ||
@@ -67,5 +102,3 @@ | ||
[npm-downloads-href]: https://npmjs.com/package/smapper | ||
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/smapper/main?style=flat&colorA=007ec6&colorB=F0DB4F | ||
[codecov-href]: https://codecov.io/gh/unjs/smapper | ||
[license-src]: https://img.shields.io/github/license/unjs/smapper.svg?style=flat&colorA=007ec6&colorB=F0DB4F | ||
[license-href]: https://github.com/unjs/smapper/blob/main/LICENSE | ||
[license-href]: https://github.com/Dave136/smapper/blob/main/README.md |
7346
102