Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 178/get interface graph ql schema #183

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ dependencies {
//compile "com.enonic.xp:core-api:${xpVersion}" // Just for apps?
//compile "com.enonic.xp:portal-api:${xpVersion}" // Just for apps?

//──────────────────────────────────────────────────────────────────────────
// Core libs (com.enonic.xp)
//──────────────────────────────────────────────────────────────────────────

//──────────────────────────────────────────────────────────────────────────
// New lib-explorer-4.0.0
//──────────────────────────────────────────────────────────────────────────
Expand All @@ -34,6 +30,8 @@ dependencies {
compile "com.enonic.xp:lib-io:${xpVersion}"
compile "com.enonic.xp:lib-scheduler:${xpVersion}"
compile "com.enonic.xp:lib-value:${xpVersion}"
compile 'com.enonic.lib:lib-graphql:2.0.1'
compile 'com.enonic.lib:lib-guillotine:5.5.0'

//──────────────────────────────────────────────────────────────────────────
// Same as lib-explorer-3.x.x
Expand All @@ -45,6 +43,9 @@ dependencies {
compile "com.enonic.xp:lib-portal:${xpVersion}"
compile "com.enonic.xp:lib-repo:${xpVersion}"
compile "com.enonic.xp:lib-task:${xpVersion}"
compile 'com.enonic.lib:lib-cache:2.1.1'
compile 'com.enonic.lib:lib-http-client:3.1.0'
compile 'com.enonic.lib:lib-license:3.0.0'

//──────────────────────────────────────────────────────────────────────────
// No longer needed in lib-explorer-4.0.0
Expand All @@ -55,13 +56,7 @@ dependencies {
//──────────────────────────────────────────────────────────────────────────
// Other enonic libs (com.enonic.lib)
//──────────────────────────────────────────────────────────────────────────
compile 'com.enonic.lib:lib-cache:2.1.1'

compile 'com.enonic.lib:lib-http-client:3.1.0'

compile 'com.enonic.lib:lib-license:3.0.0'
compile 'com.enonic.lib:lib-router:2.1.0'
//compile 'com.enonic.lib:menu:1.3.3'

//compile 'com.enonic.lib:text-encoding:1.2.0'
compile 'com.enonic.lib:lib-util:3.0.0'
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@types/mocha": "^9",
"@types/node": "^18",
"@types/react": "^18.0.10",
"@types/set-value": "^4.0.1",
"@types/traverse": "^0.6.32",
"@typescript-eslint/eslint-plugin": "^5",
"@typescript-eslint/parser": "^5",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const GQL_INPUT_TYPE_AGGREGATION = 'AggregationInput';
export const GQL_INPUT_TYPE_AGGREGATION_RANGE = 'RangeAggregationInput';
export const GQL_INPUT_TYPE_AGGREGATION_DATE_HISTOGRAM = 'DateHistogramAggregationInput';
export const GQL_INPUT_TYPE_AGGREGATION_DATE_RANGE = 'DateRangeAggregationInput';
export const GQL_INPUT_TYPE_AGGREGATION_GEO_DISTANCE = 'GeoDistanceAggregationInput';
export const GQL_INPUT_TYPE_AGGREGATION_MAX = 'MaxAggregationInput';
export const GQL_INPUT_TYPE_AGGREGATION_MIN = 'MinAggregationInput';
export const GQL_INPUT_TYPE_AGGREGATION_STATS = 'StatsAggregationInput';
export const GQL_INPUT_TYPE_AGGREGATION_TERMS = 'TermsAggregationInput';
export const GQL_INPUT_TYPE_AGGREGATION_VALUE_COUNT = 'ValueCountAggregationInput';

export const GQL_INPUT_TYPE_DATE_RANGE = 'DateRangeInput';
export const GQL_INPUT_TYPE_GEO_POINT = 'GeoPointInput';
export const GQL_INPUT_TYPE_NUMBER_RANGE = 'NumberRangeInput';
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import type {GraphQL} from '../../../index.d';
import type {Glue} from '../../../utils/Glue';


import {
GraphQLString,
list,
reference
//@ts-ignore
} from '/lib/graphql';
import {
GQL_INPUT_TYPE_AGGREGATION//,
//GQL_INPUT_TYPE_AGGREGATION_RANGE,
//GQL_INPUT_TYPE_AGGREGATION_DATE_HISTOGRAM,
//GQL_INPUT_TYPE_AGGREGATION_DATE_RANGE,
//GQL_INPUT_TYPE_AGGREGATION_GEO_DISTANCE,
//GQL_INPUT_TYPE_AGGREGATION_MAX,
//GQL_INPUT_TYPE_AGGREGATION_MIN,
//GQL_INPUT_TYPE_AGGREGATION_STATS,
//GQL_INPUT_TYPE_AGGREGATION_TERMS,
//GQL_INPUT_TYPE_AGGREGATION_VALUE_COUNT
} from '../constants';
import {addDateHistogramAggregationInput} from './addDateHistogramAggregationInput';
import {addDateRangeAggregationInput} from './addDateRangeAggregationInput';
import {addDateRangeInput} from './addDateRangeInput';
import {addGeoDistanceAggregationInput} from './addGeoDistanceAggregationInput';
import {addGeoPointInput} from './addGeoPointInput';
import {addMaxAggregationInput} from './addMaxAggregationInput';
import {addMinAggregationInput} from './addMinAggregationInput';
import {addNumberRangeInput} from './addNumberRangeInput';
import {addRangeAggregationInput} from './addRangeAggregationInput';
import {addStatsAggregationInput} from './addStatsAggregationInput';
import {addTermsAggregationInput} from './addTermsAggregationInput';
import {addValueCountAggregationInput} from './addValueCountAggregationInput';


export function addAggregationInput({
fieldType = GraphQLString, // What guillotine uses
glue
} :{
fieldType ?:GraphQL.ArgsType
glue :Glue
}) {
addDateRangeInput({glue});
addGeoPointInput({glue});
addNumberRangeInput({glue});
return glue.addInputType({
name: GQL_INPUT_TYPE_AGGREGATION,
description: 'Aggregation input type',
fields: {
subAggregations: {
type: list(reference(GQL_INPUT_TYPE_AGGREGATION))
},
name: {
type: GraphQLString
},
terms: {
type: addTermsAggregationInput({fieldType, glue})
//type: glue.getInputType(GQL_INPUT_TYPE_AGGREGATION_TERMS)
},
stats: {
type: addStatsAggregationInput({fieldType, glue})
//type: glue.getInputType(GQL_INPUT_TYPE_AGGREGATION_STATS)
},
range: {
type: addRangeAggregationInput({fieldType, glue})
//type: glue.getInputType(GQL_INPUT_TYPE_AGGREGATION_RANGE)
},
dateRange: {
type: addDateRangeAggregationInput({fieldType, glue})
//type: glue.getInputType(GQL_INPUT_TYPE_AGGREGATION_DATE_RANGE)
},
dateHistogram: {
type: addDateHistogramAggregationInput({fieldType, glue})
//type: glue.getInputType(GQL_INPUT_TYPE_AGGREGATION_DATE_HISTOGRAM)
},
geoDistance: {
type: addGeoDistanceAggregationInput({fieldType, glue})
//type: glue.getInputType(GQL_INPUT_TYPE_AGGREGATION_GEO_DISTANCE)
},
min: {
type: addMinAggregationInput({fieldType, glue})
//type: glue.getInputType(GQL_INPUT_TYPE_AGGREGATION_MIN)
},
max: {
type: addMaxAggregationInput({fieldType, glue})
//type: glue.getInputType(GQL_INPUT_TYPE_AGGREGATION_MAX)
},
count: {
type: addValueCountAggregationInput({glue})
//type: glue.getInputType(GQL_INPUT_TYPE_AGGREGATION_VALUE_COUNT)
}
}
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import type {GraphQL} from '../../../index.d';
import type {Glue} from '../../../utils/Glue';


import {
GraphQLInt,
GraphQLString,
nonNull
//@ts-ignore
} from '/lib/graphql';
import {
GQL_INPUT_TYPE_AGGREGATION_GEO_DISTANCE
} from '../constants';


export function addDateHistogramAggregationInput({
fieldType = GraphQLString, // What guillotine uses
glue
} :{
fieldType ?:GraphQL.ArgsType
glue :Glue
}) {
return glue.addInputType({
name: GQL_INPUT_TYPE_AGGREGATION_GEO_DISTANCE,
description: 'DateHistogram aggregation input type',
fields: {
field: {
type: nonNull(fieldType)
},
interval: {
type: GraphQLString
},
format: {
type: GraphQLString
},
minDocCount: {
type: GraphQLInt
}
}
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import type {GraphQL} from '../../../index.d';
import type {Glue} from '../../../utils/Glue';


import {
GraphQLString,
nonNull
//@ts-ignore
} from '/lib/graphql';
import {
GQL_INPUT_TYPE_AGGREGATION_DATE_RANGE,
GQL_INPUT_TYPE_DATE_RANGE
} from '../constants';


export function addDateRangeAggregationInput({
fieldType = GraphQLString, // What guillotine uses
glue
} :{
fieldType ?:GraphQL.ArgsType
glue :Glue
}) {
return glue.addInputType({
name: GQL_INPUT_TYPE_AGGREGATION_DATE_RANGE,
description: 'DateRange aggregation input type',
fields: {
field: {
type: nonNull(fieldType)
},
format: {
type: GraphQLString
},
ranges: {
type: glue.getInputType(GQL_INPUT_TYPE_DATE_RANGE)
}
}
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type {Glue} from '../../../utils/Glue';


//@ts-ignore
import {GraphQLString} from '/lib/graphql';
import {GQL_INPUT_TYPE_DATE_RANGE} from '../constants';


export function addDateRangeInput({glue} :{glue :Glue}) {
return glue.addInputType({
name: GQL_INPUT_TYPE_DATE_RANGE,
description: 'Number range input type',
fields: {
from: {
type: GraphQLString
},
to: {
type: GraphQLString
}
}
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type {GraphQL} from '../../../index.d';
import type {Glue} from '../../../utils/Glue';


import {
GraphQLString,
nonNull
//@ts-ignore
} from '/lib/graphql';
import {
GQL_INPUT_TYPE_AGGREGATION_DATE_HISTOGRAM,
GQL_INPUT_TYPE_GEO_POINT,
GQL_INPUT_TYPE_NUMBER_RANGE
} from '../constants';


export function addGeoDistanceAggregationInput({
fieldType = GraphQLString, // What guillotine uses
glue
} :{
fieldType ?:GraphQL.ArgsType
glue :Glue
}) {
return glue.addInputType({
name: GQL_INPUT_TYPE_AGGREGATION_DATE_HISTOGRAM,
description: 'GeoDistance aggregation input type',
fields: {
field: {
type: nonNull(fieldType)
},
unit: {
type: GraphQLString
},
origin: {
type: glue.getInputType(GQL_INPUT_TYPE_GEO_POINT)
},
ranges: {
type: glue.getInputType(GQL_INPUT_TYPE_NUMBER_RANGE)
}
}
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type {Glue} from '../../../utils/Glue';


//@ts-ignore
import {GraphQLString} from '/lib/graphql';
import {GQL_INPUT_TYPE_GEO_POINT} from '../constants';


export function addGeoPointInput({glue} :{glue :Glue}) {
return glue.addInputType({
name: GQL_INPUT_TYPE_GEO_POINT,
description: 'GeoPoint range input type',
fields: {
lat: {
type: GraphQLString
},
lon: {
type: GraphQLString
}
}
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type {GraphQL} from '../../../index.d';
import type {Glue} from '../../../utils/Glue';


import {
GraphQLString,
nonNull
//@ts-ignore
} from '/lib/graphql';
import {GQL_INPUT_TYPE_AGGREGATION_MAX} from '../constants';


export function addMaxAggregationInput({
fieldType = GraphQLString, // What guillotine uses
glue
} :{
fieldType ?:GraphQL.ArgsType
glue :Glue
}) {
return glue.addInputType({
name: GQL_INPUT_TYPE_AGGREGATION_MAX,
description: 'MaxAggregation input type',
fields: {
field: {
type: nonNull(fieldType)
}
}
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type {GraphQL} from '../../../index.d';
import type {Glue} from '../../../utils/Glue';


import {
GraphQLString,
nonNull
//@ts-ignore
} from '/lib/graphql';
import {GQL_INPUT_TYPE_AGGREGATION_MIN} from '../constants';


export function addMinAggregationInput({
fieldType = GraphQLString, // What guillotine uses
glue
} :{
fieldType ?:GraphQL.ArgsType
glue :Glue
}) {
return glue.addInputType({
name: GQL_INPUT_TYPE_AGGREGATION_MIN,
description: 'MinAggregation input type',
fields: {
field: {
type: nonNull(fieldType)
}
}
});
}
Loading