Skip to content

Commit a4b0002

Browse files
committed
fix: complete code refactoring due graphql-compose@6
1 parent b648bf8 commit a4b0002

File tree

124 files changed

+2172
-2052
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+2172
-2052
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ Live demo of [Introspection of Elasticsearch API via Graphiql](https://graphql-c
5050

5151
---
5252

53-
## TypeComposer from Elastic mapping
53+
## ObjectTypeComposer from Elastic mapping
5454

5555
In other side this module is a plugin for [graphql-compose](https://github.com/graphql-compose/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).
5656

57-
Generated TypeComposer model has several awesome resolvers:
57+
Generated ObjectTypeComposer model has several awesome resolvers:
5858

5959
- `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.
6060
- `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.

examples/elastic50/schema.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* @flow */
22

33
import elasticsearch from 'elasticsearch';
4-
import { graphql, TypeComposer } from 'graphql-compose';
4+
import { graphql, ObjectTypeComposer } from 'graphql-compose';
55
import { composeWithElastic, elasticApiFieldConfig } from '../../src'; // from 'graphql-compose-elasticsearch';
66

77
const { GraphQLSchema, GraphQLObjectType } = graphql;
@@ -94,15 +94,15 @@ const UserEsTC = composeWithElastic({
9494
elasticMapping: demoUserMapping,
9595
elasticClient: new elasticsearch.Client({
9696
host: 'http://localhost:9200',
97-
apiVersion: '5.0',
97+
apiVersion: '5.6',
9898
log: 'trace',
9999
}),
100100
// elastic mapping does not contain information about is fields are arrays or not
101101
// so provide this information explicitly for obtaining correct types in GraphQL
102102
pluralFields: ['skills', 'languages'],
103103
});
104104

105-
const ProxyTC = TypeComposer.create(`type ProxyDebugType { source: JSON }`);
105+
const ProxyTC = ObjectTypeComposer.createTemp(`type ProxyDebugType { source: JSON }`);
106106
ProxyTC.addResolver({
107107
name: 'showArgs',
108108
kind: 'query',
@@ -132,7 +132,7 @@ const schema = new GraphQLSchema({
132132
userSearchConnection: UserEsTC.getResolver('searchConnection').getFieldConfig(),
133133
elastic50: elasticApiFieldConfig({
134134
host: 'http://user:pass@localhost:9200',
135-
apiVersion: '5.0',
135+
apiVersion: '5.6',
136136
log: 'trace',
137137
}),
138138
},

examples/elastic50/seedData.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ const client = new elasticsearch.Client({
1111
const body = [];
1212
seedData.forEach(row => {
1313
const { id, ...restData } = row;
14-
body.push(
15-
{ index: { _index: 'demo_user', _type: 'demo_user', _id: id } },
16-
restData
17-
);
14+
body.push({ index: { _index: 'demo_user', _type: 'demo_user', _id: id } }, restData);
1815
});
1916

2017
client

0 commit comments

Comments
 (0)