|
1 | 1 | /* @flow */
|
2 | 2 |
|
3 | 3 | import elasticsearch from 'elasticsearch';
|
4 |
| -import { graphql } from 'graphql-compose'; |
| 4 | +import { graphql, TypeComposer } from 'graphql-compose'; |
5 | 5 | import { composeWithElastic, elasticApiFieldConfig } from '../../src'; // from 'graphql-compose-elasticsearch';
|
6 | 6 |
|
7 | 7 | const { GraphQLSchema, GraphQLObjectType } = graphql;
|
@@ -102,12 +102,34 @@ const UserEsTC = composeWithElastic({
|
102 | 102 | pluralFields: ['skills', 'languages'],
|
103 | 103 | });
|
104 | 104 |
|
| 105 | +const ProxyTC = TypeComposer.create(`type ProxyDebugType { source: JSON }`); |
| 106 | +ProxyTC.addResolver({ |
| 107 | + name: 'showArgs', |
| 108 | + kind: 'query', |
| 109 | + args: { |
| 110 | + source: 'JSON', |
| 111 | + }, |
| 112 | + type: 'ProxyDebugType', |
| 113 | + resolve: ({ args }) => args, |
| 114 | +}); |
| 115 | + |
| 116 | +UserEsTC.addRelation('showRelationArguments', { |
| 117 | + resolver: () => ProxyTC.getResolver('showArgs'), |
| 118 | + prepareArgs: { |
| 119 | + source: source => source, |
| 120 | + }, |
| 121 | + projection: { |
| 122 | + name: true, |
| 123 | + salary: true, |
| 124 | + }, |
| 125 | +}); |
| 126 | + |
105 | 127 | const schema = new GraphQLSchema({
|
106 | 128 | query: new GraphQLObjectType({
|
107 | 129 | name: 'Query',
|
108 | 130 | fields: {
|
109 |
| - user: UserEsTC.getResolver('search').getFieldConfig(), |
110 |
| - userConnection: UserEsTC.getResolver('searchConnection').getFieldConfig(), |
| 131 | + userSearch: UserEsTC.getResolver('search').getFieldConfig(), |
| 132 | + userSearchConnection: UserEsTC.getResolver('searchConnection').getFieldConfig(), |
111 | 133 | elastic50: elasticApiFieldConfig({
|
112 | 134 | host: 'http://user:pass@localhost:9200',
|
113 | 135 | apiVersion: '5.0',
|
|
0 commit comments