-
Notifications
You must be signed in to change notification settings - Fork 13
/
geo-point.ts
33 lines (30 loc) · 1.08 KB
/
geo-point.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { xLuceneFieldType, ESFieldType, xLuceneTypeConfig } from '@terascope/types';
import BaseType, { ToGraphQLOptions } from '../base-type';
import { GraphQLType, TypeESMapping } from '../../interfaces';
export default class GeoPointType extends BaseType {
toESMapping(): TypeESMapping {
this._validateESMapping();
return {
mapping: {
[this.field]: this.config.indexed === false ? {
type: 'geo_point' as ESFieldType,
index: false
} : { type: 'geo_point' as ESFieldType }
}
};
}
toGraphQL({ isInput }: ToGraphQLOptions = {}): GraphQLType {
const defType = isInput ? 'input' : 'type';
const name = this._formatGQLTypeName('GeoPoint', isInput);
const customType = `
${defType} ${name} {
lat: String!
lon: String!
}
`;
return this._formatGql(name, customType);
}
toXlucene(): xLuceneTypeConfig {
return { [this.field]: xLuceneFieldType.GeoPoint };
}
}