@lde/search-api-graphql 0.13.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-schema.d.ts.map +1 -1
- package/dist/build-schema.js +22 -17
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-schema.d.ts","sourceRoot":"","sources":["../src/build-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,aAAa,EAQd,MAAM,SAAS,CAAC;AACjB,OAAO,EAIL,KAAK,YAAY,EAEjB,KAAK,WAAW,EAChB,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"build-schema.d.ts","sourceRoot":"","sources":["../src/build-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,aAAa,EAQd,MAAM,SAAS,CAAC;AACjB,OAAO,EAIL,KAAK,YAAY,EAEjB,KAAK,WAAW,EAChB,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;AAYrB,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAGvB,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC5B;;sDAEkD;IAClD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,mFAAmF;IACnF,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACjE;AAED;2EAC2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC;yCACqC;IACrC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;uBACmB;IACnB,QAAQ,CAAC,aAAa,CAAC,EAAE,CACvB,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,aAAa,KACnB,WAAW,CAAC;CAClB;AAED,MAAM,WAAW,yBAAyB;IACxC;;kEAE8D;IAC9D,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAC7D,+EAA+E;IAC/E,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACvC;;gDAE4C;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAkBD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,yBAA8B,GACtC,aAAa,CA6Xf;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAER"}
|
package/dist/build-schema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GraphQLBoolean, GraphQLEnumType, GraphQLFloat, GraphQLInputObjectType, GraphQLInt, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLSchema, GraphQLString, printSchema, } from 'graphql';
|
|
2
|
-
import { facetableFields, filterableFields, filterOperatorFor, isRangeFacet, outputFields, pageForOffset, sortableFields, unixSecondsToIso, } from '@lde/search/adapter';
|
|
2
|
+
import { facetableFields, filterableFields, filterOperatorFor, ID_FIELD, isRangeFacet, outputFields, pageForOffset, sortableFields, unixSecondsToIso, } from '@lde/search/adapter';
|
|
3
3
|
import { defaultLanguageOrder, toLanguageStrings, } from './language.js';
|
|
4
4
|
import { createFacetLoader } from './facet-batch.js';
|
|
5
5
|
const nonNullListOf = (type) => new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(type)));
|
|
@@ -206,22 +206,22 @@ export function buildGraphQLSchema(schema, options = {}) {
|
|
|
206
206
|
return fields;
|
|
207
207
|
},
|
|
208
208
|
});
|
|
209
|
-
//
|
|
210
|
-
//
|
|
211
|
-
//
|
|
209
|
+
// Every type is filterable on `id`, so the input always has at least one
|
|
210
|
+
// field and always exists – no type is unaddressable by IRI, whatever it
|
|
211
|
+
// declares.
|
|
212
212
|
const filterable = filterableFields(searchType);
|
|
213
|
-
const whereInput =
|
|
214
|
-
|
|
215
|
-
:
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
213
|
+
const whereInput = new GraphQLInputObjectType({
|
|
214
|
+
name: `${typeName}Where`,
|
|
215
|
+
fields: () => {
|
|
216
|
+
const fields = {
|
|
217
|
+
[ID_FIELD]: { type: stringFilter },
|
|
218
|
+
};
|
|
219
|
+
for (const field of filterable) {
|
|
220
|
+
fields[field.name] = { type: whereFieldType(field) };
|
|
221
|
+
}
|
|
222
|
+
return fields;
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
225
|
const sortValues = {
|
|
226
226
|
RELEVANCE: { value: 'relevance' },
|
|
227
227
|
};
|
|
@@ -270,7 +270,7 @@ export function buildGraphQLSchema(schema, options = {}) {
|
|
|
270
270
|
type: new GraphQLNonNull(resultType),
|
|
271
271
|
args: {
|
|
272
272
|
query: { type: GraphQLString },
|
|
273
|
-
|
|
273
|
+
where: { type: whereInput },
|
|
274
274
|
orderBy: { type: orderByInput },
|
|
275
275
|
page: { type: GraphQLInt, defaultValue: 1 },
|
|
276
276
|
perPage: { type: GraphQLInt, defaultValue: 20 },
|
|
@@ -372,6 +372,11 @@ function whereToFilters(where, searchType) {
|
|
|
372
372
|
return [];
|
|
373
373
|
}
|
|
374
374
|
const filters = [];
|
|
375
|
+
// `id` first: it is declared by no type, so the field loop below never sees it.
|
|
376
|
+
const id = where[ID_FIELD];
|
|
377
|
+
if (id !== undefined && id !== null) {
|
|
378
|
+
filters.push({ field: ID_FIELD, in: id.in ?? [] });
|
|
379
|
+
}
|
|
375
380
|
for (const field of filterableFields(searchType)) {
|
|
376
381
|
const value = where[field.name];
|
|
377
382
|
if (value === undefined || value === null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/search-api-graphql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Engine- and domain-agnostic GraphQL surface for @lde/search: builds an executable GraphQLSchema from a whole SearchSchema at runtime (no codegen) – one root query field per SearchType – served by generic resolvers over any SearchEngine – and serves it as a framework-agnostic fetch handler with a self-contained playground, SDL endpoint, CORS and depth/cost limits. You supply the schema and per-type typeNames; it names neither your domain nor your engine.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "git+https://github.com/ldelements/lde.git",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@escape.tech/graphql-armor-cost-limit": "^2.4.3",
|
|
29
29
|
"@escape.tech/graphql-armor-max-depth": "^2.4.2",
|
|
30
30
|
"@graphql-yoga/render-graphiql": "^5.21.2",
|
|
31
|
-
"@lde/search": "^0.
|
|
31
|
+
"@lde/search": "^0.14.0",
|
|
32
32
|
"dataloader": "^2.2.3",
|
|
33
33
|
"graphql": "^16.0.0",
|
|
34
34
|
"graphql-yoga": "^5.21.2",
|