@faststore/api 1.3.22 → 1.3.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +35 -0
- package/README.md +44 -102
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,41 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 1.3.26 (2021-12-09)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @faststore/api
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 1.3.25 (2021-12-09)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @faststore/api
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## 1.3.24 (2021-12-09)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* fix UI storybook imports ([#1069](https://github.com/vtex/faststore/issues/1069)) ([e4a2402](https://github.com/vtex/faststore/commit/e4a2402235c60488fde7021bf3200d967af3cb83))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## 1.3.23 (2021-12-09)
|
|
34
|
+
|
|
35
|
+
**Note:** Version bump only for package @faststore/api
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
6
41
|
## 1.3.22 (2021-12-07)
|
|
7
42
|
|
|
8
43
|
**Note:** Version bump only for package @faststore/api
|
package/README.md
CHANGED
|
@@ -1,115 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://faststore.dev">
|
|
3
|
+
<img alt="Faststore" src="../ui/static/logo.png" width="60" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
6
|
+
<h1 align="center">
|
|
7
|
+
FastStore API
|
|
8
|
+
</h1>
|
|
9
|
+
<p align="center">
|
|
10
|
+
<strong>
|
|
11
|
+
Connect to your favorite ecommerce platform
|
|
12
|
+
</strong>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<div style="display: flex; justify-content: center; width: 100%">
|
|
16
|
+
<a href="https://www.npmjs.com/package/@faststore/api" style="padding: 0px 2px 0px 0px">
|
|
17
|
+
<img src="https://badge.fury.io/js/%40faststore%2Fui.svg" />
|
|
18
|
+
</a>
|
|
19
|
+
<a href="https://bundlephobia.com/package/@faststore/api" style="padding: 0px 0px 0px 2px">
|
|
20
|
+
<img src="https://badgen.net/bundlephobia/dependency-count/@faststore/api" />
|
|
21
|
+
</a>
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
From the command line in your project directory, run yarn add `@faststore/api`.
|
|
27
|
+
|
|
28
|
+
```cmd
|
|
22
29
|
yarn add @faststore/api
|
|
23
30
|
```
|
|
24
|
-
|
|
25
31
|
## Usage
|
|
26
|
-
GraphQL is very versatile and can run in many places. To setup the schema in an apollo server, just:
|
|
27
|
-
```ts
|
|
28
|
-
import { getSchema } from '@faststore/api'
|
|
29
|
-
import { ApolloServer } from 'apollo-server'
|
|
30
|
-
|
|
31
|
-
// Get the Store schema
|
|
32
|
-
const schema = await getSchema({ platform: 'vtex', account: 'my-account', environment: 'vtexcommercestable' })
|
|
33
|
-
|
|
34
|
-
// Setup Apollo Server
|
|
35
|
-
const server = new ApolloServer({ schema });
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
server.listen().then(({ url }) => {
|
|
39
|
-
console.log(`🚀 Server ready at ${url}`);
|
|
40
|
-
});
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Extending the schema
|
|
44
|
-
GraphQL is a very versatile language. By using the exported `getSchema` function, you can not only extend the base schema but also redefine the whole resolvers implementation.
|
|
45
|
-
|
|
46
|
-
To extend the schema, one can:
|
|
33
|
+
With servers like express:
|
|
47
34
|
```ts
|
|
35
|
+
import { execute } from 'graphql'
|
|
48
36
|
import { getSchema } from '@faststore/api'
|
|
49
|
-
import { makeExecutableSchema, mergeSchemas } from '@graphql-tools/schema'
|
|
50
|
-
import { ApolloServer } from 'apollo-server'
|
|
51
37
|
|
|
52
|
-
|
|
53
|
-
const typeDefs = `
|
|
54
|
-
extend type Product {
|
|
55
|
-
customField: String!
|
|
56
|
-
}
|
|
57
|
-
`
|
|
38
|
+
import express from 'express'
|
|
58
39
|
|
|
59
|
-
|
|
60
|
-
const resolvers = {
|
|
61
|
-
Product: {
|
|
62
|
-
customField: async () => {
|
|
63
|
-
...
|
|
64
|
-
// Your code goes here
|
|
65
|
-
...
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
40
|
+
const app = express()
|
|
69
41
|
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
const storeApiSchema = await getSchema({ platform: 'vtex', ...})
|
|
42
|
+
app.get('/graphql', async (req, res) => {
|
|
43
|
+
const { query, operationName, variables } = req.body
|
|
73
44
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
45
|
+
const result = await execute({
|
|
46
|
+
schema: await getSchema(),
|
|
47
|
+
variableValues: variables,
|
|
48
|
+
operationName
|
|
49
|
+
})
|
|
79
50
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// The `listen` method launches a web server.
|
|
84
|
-
server.listen().then(({ url }) => {
|
|
85
|
-
console.log(`🚀 Server ready at ${url}`);
|
|
86
|
-
});
|
|
51
|
+
res.status(200)
|
|
52
|
+
res.send(result)
|
|
53
|
+
})
|
|
87
54
|
```
|
|
88
55
|
|
|
89
|
-
##
|
|
90
|
-
|
|
91
|
-
1. Make a contribution
|
|
92
|
-
2. Create inline resolvers for your platform
|
|
93
|
-
|
|
94
|
-
Inline resolves means you are going to write all resolvers for the api schema in your project or in an external library. This is recommended if you are supporting a niche platform and want to have full control over how each field is processed.
|
|
95
|
-
|
|
96
|
-
To create your own resolvers, you can:
|
|
97
|
-
```ts
|
|
98
|
-
import { getTypeDefs } from '@faststore/api'
|
|
99
|
-
import { ApolloServer } from 'apollo-server'
|
|
100
|
-
import { makeExecutableSchema } from '@graphql-tools/schema'
|
|
101
|
-
|
|
102
|
-
// Get the Store API TypeDefs
|
|
103
|
-
const typeDefs = getTypeDefs()
|
|
104
|
-
|
|
105
|
-
const resolvers = {
|
|
106
|
-
...
|
|
107
|
-
// add your resolvers
|
|
108
|
-
...
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Create a runnable schema
|
|
112
|
-
const schema = makeExecutableSchema({ resolvers, typeDefs })
|
|
113
|
-
|
|
114
|
-
// You now have a runnable GraphQL schema, you can create a server or run queries locally.
|
|
115
|
-
```
|
|
56
|
+
## Docs
|
|
57
|
+
For more information, please refer to our documentation: https://faststore.dev/reference/api/overview
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/api",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.26",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"graphql": "^15.6.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "f8ce80cf4bcdfd2d307cad3ae506bc1193f4c4d0"
|
|
46
46
|
}
|