@financial-times/cp-content-pipeline-client 0.6.1 → 0.6.3
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 +24 -0
- package/README.md +10 -2
- package/codegen.js +34 -0
- package/lib/generated/index.d.ts +10425 -7872
- package/lib/generated/index.js +1 -1
- package/lib/generated/index.js.map +1 -1
- package/lib/schema-version.d.ts +1 -1
- package/lib/schema-version.js +1 -1
- package/lib/type-assertions.d.ts +1 -0
- package/lib/type-assertions.js +23 -0
- package/lib/type-assertions.js.map +1 -0
- package/package.json +6 -3
- package/queries/article.graphql +1 -1
- package/src/generated/index.ts +104 -149
- package/src/schema-version.ts +1 -1
- package/src/type-assertions.ts +37 -0
- package/tsconfig.json +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/codegen.yml +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -126,6 +126,30 @@
|
|
|
126
126
|
* devDependencies
|
|
127
127
|
* @financial-times/cp-content-pipeline-schema bumped from ^0.7.0 to ^0.7.1
|
|
128
128
|
|
|
129
|
+
### Dependencies
|
|
130
|
+
|
|
131
|
+
* The following workspace dependencies were updated
|
|
132
|
+
* devDependencies
|
|
133
|
+
* @financial-times/cp-content-pipeline-schema bumped from ^0.7.2 to ^0.7.3
|
|
134
|
+
|
|
135
|
+
## [0.6.2](https://github.com/Financial-Times/cp-content-pipeline/compare/cp-content-pipeline-client-v0.6.1...cp-content-pipeline-client-v0.6.2) (2023-03-16)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
### Features
|
|
139
|
+
|
|
140
|
+
* add a way of asserting our fragments are compatible with content-tree ([86ddeab](https://github.com/Financial-Times/cp-content-pipeline/commit/86ddeab8ad66c96ff2e6e700cae82236171858b4))
|
|
141
|
+
* add more content-tree/fragment type assertions ([412441b](https://github.com/Financial-Times/cp-content-pipeline/commit/412441b6270e8aa4eca4809e90a4140892db0e67))
|
|
142
|
+
* generate types for scalars ([0ce155e](https://github.com/Financial-Times/cp-content-pipeline/commit/0ce155e64ce9691dde2b123963d5159d89f5b18d))
|
|
143
|
+
* include id property in image responses ([de16578](https://github.com/Financial-Times/cp-content-pipeline/commit/de165784f7a26a3173f9e9b5a95b89e21c1e30ef))
|
|
144
|
+
* remove unused alt field from image fragment (it's on the imageset) ([9c6d58f](https://github.com/Financial-Times/cp-content-pipeline/commit/9c6d58f9a90b307cb96c7a21551d6227d92aaafb))
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
### Dependencies
|
|
148
|
+
|
|
149
|
+
* The following workspace dependencies were updated
|
|
150
|
+
* devDependencies
|
|
151
|
+
* @financial-times/cp-content-pipeline-schema bumped from ^0.7.1 to ^0.7.2
|
|
152
|
+
|
|
129
153
|
## [0.6.0](https://github.com/Financial-Times/cp-content-pipeline/compare/cp-content-pipeline-client-v0.5.11...cp-content-pipeline-client-v0.6.0) (2023-03-14)
|
|
130
154
|
|
|
131
155
|
|
package/README.md
CHANGED
|
@@ -16,8 +16,8 @@ The project has its own playground ui at the url it's running on.
|
|
|
16
16
|
import initContentPipelineClient from '@financial-times/cp-content-pipeline-client'
|
|
17
17
|
|
|
18
18
|
const client = initContentPipelineClient({
|
|
19
|
-
baseUrl: 'http://localhost:3001',
|
|
20
|
-
systemCode: 'cp-content-pipeline',
|
|
19
|
+
baseUrl: 'http://localhost:3001', // for testing purposes only
|
|
20
|
+
systemCode: 'cp-content-pipeline', // your consuming app's Biz Ops system code
|
|
21
21
|
timeout: 2000 // default = 1 minute
|
|
22
22
|
})
|
|
23
23
|
|
|
@@ -27,6 +27,14 @@ const { content: articleData } = await client.Article({
|
|
|
27
27
|
})
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
### URLs and versioning
|
|
31
|
+
|
|
32
|
+
The client requests versions of the API based on the version of the schema it has installed as a dependency. For example, a client that depends on `@financial-times/cp-content-pipeline-schema` 0.7.x will send requests to `https://www.ft.com/__content/v0.7`.
|
|
33
|
+
|
|
34
|
+
When we release a new major version of the schema, we'll release a new major version of the client alongside it, so consuming apps can install the new version of the client to get the breaking schema changes, and consumers still depending on the old client version will get the old schema.
|
|
35
|
+
|
|
36
|
+
The `baseUrl` option overrides this logic, and forces all requests to go to that URL, without the version suffix. This means if you're overriding `baseUrl`, you're opting out of having the client handle versioning for you. For this reason, **`baseUrl` should only be used for testing purposes**, e.g. to force the client to send requests to a locally-running API.
|
|
37
|
+
|
|
30
38
|
## How this package is produced
|
|
31
39
|
|
|
32
40
|
The published `cp-content-pipeline-client` package mainly consists of generated code which is the output of [@graphql-codegen](https://www.npmjs.com/package/@graphql-codegen/cli).
|
package/codegen.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const { scalars } = require('@financial-times/cp-content-pipeline-schema')
|
|
2
|
+
const mapValues = require('lodash.mapvalues')
|
|
3
|
+
|
|
4
|
+
const config = {
|
|
5
|
+
schema: [
|
|
6
|
+
{
|
|
7
|
+
schema: {
|
|
8
|
+
loader: './loader.js',
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
documents: 'queries/*.graphql',
|
|
13
|
+
generates: {
|
|
14
|
+
'src/generated/index.ts': {
|
|
15
|
+
plugins: [
|
|
16
|
+
'typescript',
|
|
17
|
+
'typescript-operations',
|
|
18
|
+
'typescript-graphql-request',
|
|
19
|
+
],
|
|
20
|
+
config: {
|
|
21
|
+
// discourage transforming data in consumers by making properties readonly
|
|
22
|
+
immutableTypes: true,
|
|
23
|
+
// make types better-compatible with React, which doesn't like null
|
|
24
|
+
maybeValue: 'T',
|
|
25
|
+
// output types for custom scalars
|
|
26
|
+
scalars: mapValues(scalars, (scalar) => scalar.codegenType),
|
|
27
|
+
// don't ouptput __typename unless requested
|
|
28
|
+
skipTypename: true,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = config
|