Skip to content

Commit 587046d

Browse files
committed
docs: Update screenshots, small fixes
1 parent 6b1b561 commit 587046d

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

README.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This module expose Elastic Search REST API via GraphQL.
1313
Supported all elastic versions that support official [elasticsearch-js](https://github.com/elastic/elasticsearch-js) client. Internally it parses its source code annotations and generates all available methods with params and descriptions to GraphQL Field Config Map. You may put this config map to any GraphQL Schema.
1414

1515
```js
16+
import { GraphQLSchema, GraphQLObjectType } from 'graphql';
1617
import elasticsearch from 'elasticsearch';
1718
import { elasticApiFieldConfig } from 'graphql-compose-elasticsearch';
1819

@@ -45,15 +46,23 @@ const schema = new GraphQLSchema({
4546

4647
Full [code example](https://github.com/nodkz/graphql-compose-elasticsearch/tree/master/examples/differentVersions)
4748

49+
Live demo of [Introspection of Elasticsearch API via Graphiql](https://graphql-compose.herokuapp.com/elasticsearch/)
50+
51+
---
52+
4853
## TypeComposer from Elastic mapping
49-
In other side this module is a plugin for [graphql-compose](https://github.com/nodkz/graphql-compose), which derives GraphQLType from your [elastic mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html) generates input fields for all available methods in QueryDSL, Aggregations, Sorting with field autocompletion according to types in your mapping (like query dev tool in Kibana).
54+
In other side this module is a plugin for [graphql-compose](https://github.com/nodkz/graphql-compose), which derives GraphQLType from your [elastic mapping](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html) generates tons of types, provides all available methods in QueryDSL, Aggregations, Sorting with field autocompletion according to types in your mapping (like Dev Tools Console in Kibana).
5055

51-
Generated TypeComposer has several awesome resolvers:
52-
- `search` - greatly simplified `search` method. According to GraphQL adaptation and its projection bunch of params setup automatically due your graphql query.
53-
- `searchConnection` - `search` method that implements Relay Cursor Connection [spec](https://facebook.github.io/relay/graphql/connections.htm) for infinite lists. Internally it uses cheap [search_after](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-after.html) API. One downside, Elastic does not support backward scrolling, so `before` argument will not work.
56+
Generated TypeComposer model has several awesome resolvers:
57+
- `search` - greatly simplified elastic `search` method. According to GraphQL adaptation and its projection bunch of params setup automatically due your graphql query (eg `_source`, `explain`, `version`, `trackScores`), other rare fine tuning params moved to `opts` input field.
58+
- `searchConnection` - elastic `search` method that implements Relay Cursor Connection [spec](https://facebook.github.io/relay/graphql/connections.htm) for infinite lists. Internally it uses cheap [search_after](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-after.html) API. One downside, Elastic does not support backward scrolling, so `before` argument will not work.
5459
- more resolvers will be later after my vacation: `suggest`, `getById`, `updateById` and others
5560

5661
```js
62+
import { GraphQLSchema, GraphQLObjectType } from 'graphql';
63+
import elasticsearch from 'elasticsearch';
64+
import { composeWithElastic } from 'graphql-compose-elasticsearch';
65+
5766
const mapping = {
5867
properties: {
5968
name: {
@@ -125,13 +134,20 @@ npm install graphql graphql-compose elasticsearch graphql-compose-elasticsearch
125134
```
126135
Modules `graphql`, `graphql-compose`, `elasticsearch` are in `peerDependencies`, so should be installed explicitly in your app.
127136

128-
## Live demos
129-
[Introspection of Elasticsearch API via Graphiql](https://graphql-compose.herokuapp.com/elasticsearch/)
137+
## Screenshots
130138

139+
### API proxy: Raw search method
131140
<img width="1316" alt="screen shot 2017-03-07 at 22 26 17" src="https://cloud.githubusercontent.com/assets/1946920/23859886/61066f40-082f-11e7-89d0-8443aa2ae930.png">
132141

142+
### API proxy: Getting several raw elastic metric in one request
133143
<img width="1314" alt="screen shot 2017-03-07 at 22 34 01" src="https://cloud.githubusercontent.com/assets/1946920/23859892/65e71744-082f-11e7-8c1a-cafeb87e08e6.png">
134144

145+
### Mapping: Relay Cursor Connection
146+
<img width="1411" alt="screen shot 2017-03-22 at 19 34 09" src="https://cloud.githubusercontent.com/assets/1946920/24200219/a058c220-0f36-11e7-9cf1-38394052f922.png">
147+
148+
### Mapping: Generated GraphQL Types and Documentation
149+
<img width="1703" alt="screen shot 2017-03-22 at 19 33 24" src="https://cloud.githubusercontent.com/assets/1946920/24200220/a05944b6-0f36-11e7-9919-39b7001af203.png">
150+
135151

136152
## License
137153
[MIT](https://github.com/nodkz/graphql-compose-elasticsearch/blob/master/LICENSE.md)

examples/elastic50/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import { composeWithElastic, elasticApiFieldConfig } from '../../src'; // from '
1010
const expressPort = process.env.port || process.env.PORT || 9201;
1111

1212
// mapping obtained from ElasticSearch server
13-
// GET http://user:pass@localhost:9200/cv/_mapping
13+
// GET http://user:pass@localhost:9200/user/_mapping
1414
const indexMapping = {
15-
cv: {
15+
user: {
1616
mappings: {
17-
cv: {
17+
user: {
1818
properties: {
1919
name: {
2020
type: 'text',
@@ -93,11 +93,11 @@ const indexMapping = {
9393
},
9494
};
9595

96-
const CvEsTC = composeWithElastic({
97-
graphqlTypeName: 'CvES',
96+
const UserEsTC = composeWithElastic({
97+
graphqlTypeName: 'UserES',
9898
elasticIndex: 'cv',
9999
elasticType: 'cv',
100-
elasticMapping: indexMapping.cv.mappings.cv,
100+
elasticMapping: indexMapping.user.mappings.user,
101101
elasticClient: new elasticsearch.Client({
102102
host: 'http://localhost:9200',
103103
apiVersion: '5.0',
@@ -112,8 +112,8 @@ const generatedSchema = new GraphQLSchema({
112112
query: new GraphQLObjectType({
113113
name: 'Query',
114114
fields: {
115-
cv: CvEsTC.get('$search').getFieldConfig(),
116-
cvConnection: CvEsTC.get('$searchConnection').getFieldConfig(),
115+
user: UserEsTC.get('$search').getFieldConfig(),
116+
userConnection: UserEsTC.get('$searchConnection').getFieldConfig(),
117117
elastic50: elasticApiFieldConfig({
118118
host: 'http://user:pass@localhost:9200',
119119
apiVersion: '5.0',

0 commit comments

Comments
 (0)