Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@searchkit/apollo-resolvers

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@searchkit/apollo-resolvers - npm Package Compare versions

Comparing version 3.0.0-canary.15 to 3.0.0-canary.16

tests/__mock-data__/FacetResolver/Facet.json

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [3.0.0-canary.16](https://github.com/searchkit/searchkit/compare/v3.0.0-canary.12...v3.0.0-canary.16) (2020-12-04)
### Bug Fixes
* better compatibility support for es6 / es7 over total ([ce6a92c](https://github.com/searchkit/searchkit/commit/ce6a92cf6e9a3f14f46f08fe9f75b38561e511b2)), closes [#792](https://github.com/searchkit/searchkit/issues/792)
# [3.0.0-canary.15](https://github.com/searchkit/searchkit/compare/v3.0.0-canary.12...v3.0.0-canary.15) (2020-12-03)

@@ -8,0 +19,0 @@

2

lib/resolvers/HitsResolver.js

@@ -35,3 +35,3 @@ "use strict";

});
const hitsTotal = (hits.total.value || hits.total);
const hitsTotal = (typeof hits.total.value === "number" ? hits.total.value : hits.total);
return {

@@ -38,0 +38,0 @@ items: hits.hits.map((hit) => ({

@@ -19,3 +19,3 @@ "use strict";

return {
total: results.hits.total.value ? results.hits.total.value : results.hits.total,
total: typeof results.hits.total.value === "number" ? results.hits.total.value : results.hits.total,
query: queryManager.getQuery(),

@@ -22,0 +22,0 @@ sortOptions: config.sortOptions.map((sortOption) => ({

{
"name": "@searchkit/apollo-resolvers",
"version": "3.0.0-canary.15",
"version": "3.0.0-canary.16",
"main": "lib/index.js",

@@ -37,5 +37,2 @@ "author": "Joseph McElroy <phoey1@gmail.com>",

"devDependencies": {
"@pollyjs/adapter-node-http": "^5.0.0",
"@pollyjs/core": "^5.0.0",
"@pollyjs/persister-fs": "^5.0.0",
"@types/node": "^13.9.1",

@@ -45,7 +42,7 @@ "@types/react": "^16.9.23",

"express": "^4.17.1",
"setup-polly-jest": "^0.9.1",
"supertest": "^4.0.2",
"nock": "^13.0.5",
"supertest": "^6.0.1",
"typescript": "^4.0.5"
},
"gitHead": "28e51fee342e7e4a227b545b10574b4ef01fc24e"
"gitHead": "729f50f60415e8665c369e96b93d2c5d4bf81d94"
}

@@ -38,3 +38,3 @@ import SearchkitRequest from '../core/SearchkitRequest'

const hitsTotal = (hits.total.value || hits.total) as number
const hitsTotal = (typeof hits.total.value === "number" ? hits.total.value : hits.total) as number

@@ -41,0 +41,0 @@ return {

@@ -13,3 +13,3 @@ import SearchkitRequest from '../core/SearchkitRequest'

return {
total: results.hits.total.value ? results.hits.total.value : results.hits.total,
total: typeof results.hits.total.value === "number" ? results.hits.total.value : results.hits.total,
query: queryManager.getQuery(),

@@ -16,0 +16,0 @@ sortOptions: config.sortOptions.map((sortOption) => ({

@@ -5,2 +5,4 @@ import { SearchkitConfig } from '../src/resolvers/ResultsResolver'

import { setupTestServer, callQuery } from './support/helper'
import nock from 'nock'
import FacetMock from './__mock-data__/FacetResolver/Facet.json'

@@ -52,2 +54,36 @@ describe('Facet Resolver', () => {

const scope = nock('http://localhost:9200')
.post('/movies/_search')
.reply((uri, body) => {
expect(body).toMatchInlineSnapshot(`
Object {
"aggs": Object {
"facet_bucket_all": Object {
"aggs": Object {
"writers": Object {
"terms": Object {
"field": "writers.raw",
"include": "[tT][eE].*",
"size": 5,
},
},
},
"filter": Object {
"bool": Object {
"must": Array [],
},
},
},
},
"post_filter": Object {
"bool": Object {
"must": Array [],
},
},
"size": 0,
}
`)
return [200, FacetMock]
})
const response = await runQuery(gql)

@@ -54,0 +90,0 @@ expect(response.body.data).toMatchSnapshot()

@@ -5,2 +5,4 @@ import { SearchkitConfig } from '../src/resolvers/ResultsResolver'

import { setupTestServer, callQuery } from './support/helper'
import nock from 'nock'
import HitsMock from './__mock-data__/FacetsResolver/results.json'

@@ -61,2 +63,59 @@ describe('Facets Resolver', () => {

const scope = nock('http://localhost:9200')
.post('/movies/_search')
.reply((uri, body) => {
expect(body).toMatchInlineSnapshot(`
Object {
"aggs": Object {
"facet_bucket_all": Object {
"aggs": Object {
"actors": Object {
"terms": Object {
"field": "actors.raw",
"size": 5,
},
},
"genres": Object {
"terms": Object {
"field": "genres.raw",
"size": 5,
},
},
"type": Object {
"terms": Object {
"field": "type.raw",
"size": 5,
},
},
"writers": Object {
"terms": Object {
"field": "writers.raw",
"size": 5,
},
},
},
"filter": Object {
"bool": Object {
"must": Array [],
},
},
},
},
"from": 0,
"post_filter": Object {
"bool": Object {
"must": Array [],
},
},
"size": 10,
"sort": Array [
Object {
"_score": "desc",
},
],
}
`)
return [200, HitsMock]
})
const response = await runQuery(gql)

@@ -99,2 +158,126 @@ expect(response.body.data).toMatchSnapshot()

const scope = nock('http://localhost:9200')
.post('/movies/_search')
.reply((uri, body) => {
expect(body).toMatchInlineSnapshot(`
Object {
"aggs": Object {
"facet_bucket_all": Object {
"aggs": Object {
"actors": Object {
"terms": Object {
"field": "actors.raw",
"size": 5,
},
},
"genres": Object {
"terms": Object {
"field": "genres.raw",
"size": 5,
},
},
"type": Object {
"terms": Object {
"field": "type.raw",
"size": 5,
},
},
},
"filter": Object {
"bool": Object {
"must": Array [
Object {
"bool": Object {
"should": Array [
Object {
"term": Object {
"writers.raw": "Damon Lindelof",
},
},
],
},
},
Object {
"bool": Object {
"must": Array [
Object {
"term": Object {
"actors.raw": "Damon Lindelof",
},
},
],
},
},
],
},
},
},
"facet_bucket_writers": Object {
"aggs": Object {
"writers": Object {
"terms": Object {
"field": "writers.raw",
"size": 5,
},
},
},
"filter": Object {
"bool": Object {
"must": Array [
Object {
"bool": Object {
"must": Array [
Object {
"term": Object {
"actors.raw": "Damon Lindelof",
},
},
],
},
},
],
},
},
},
},
"from": 0,
"post_filter": Object {
"bool": Object {
"must": Array [
Object {
"bool": Object {
"should": Array [
Object {
"term": Object {
"writers.raw": "Damon Lindelof",
},
},
],
},
},
Object {
"bool": Object {
"must": Array [
Object {
"term": Object {
"actors.raw": "Damon Lindelof",
},
},
],
},
},
],
},
},
"size": 10,
"sort": Array [
Object {
"_score": "desc",
},
],
}
`)
return [200, HitsMock]
})
const response = await runQuery(gql)

@@ -101,0 +284,0 @@

import { SearchkitConfig } from '../src/resolvers/ResultsResolver'
import { MultiMatchQuery } from '../src'
import { setupTestServer, callQuery } from './support/helper'
import nock from 'nock'
import HitsMock from './__mock-data__/HitResolver/Hits.json'

@@ -42,2 +44,25 @@ describe('Hits Resolver', () => {

const scope = nock('http://localhost:9200')
.post('/movies/_search')
.reply((uri, body) => {
expect(body).toMatchInlineSnapshot(`
Object {
"aggs": Object {},
"from": 0,
"post_filter": Object {
"bool": Object {
"must": Array [],
},
},
"size": 10,
"sort": Array [
Object {
"_score": "desc",
},
],
}
`)
return [200, HitsMock]
})
const response = await runQuery()

@@ -58,2 +83,25 @@ expect(response.body.data).toMatchSnapshot()

const scope = nock('http://localhost:9200')
.post('/movies/_search')
.reply((uri, body) => {
expect(body).toMatchInlineSnapshot(`
Object {
"aggs": Object {},
"from": 10,
"post_filter": Object {
"bool": Object {
"must": Array [],
},
},
"size": 10,
"sort": Array [
Object {
"_score": "desc",
},
],
}
`)
return [200, HitsMock]
})
setupTestServer(config)

@@ -82,5 +130,43 @@

const scope = nock('http://localhost:9200')
.post('/movies/_search')
.reply((uri, body) => {
expect(body).toMatchInlineSnapshot(`
Object {
"aggs": Object {},
"from": 10,
"post_filter": Object {
"bool": Object {
"must": Array [],
},
},
"size": 10,
"sort": "_score",
}
`)
return [200, HitsMock]
})
let response = await runQuery('', { size: 10, from: 10 }, 'relevance')
expect(response.body.data).toMatchSnapshot()
scope.post('/movies/_search').reply((uri, body) => {
expect(body).toMatchInlineSnapshot(`
Object {
"aggs": Object {},
"from": 10,
"post_filter": Object {
"bool": Object {
"must": Array [],
},
},
"size": 10,
"sort": Object {
"released": "desc",
},
}
`)
return [200, HitsMock]
})
response = await runQuery('', { size: 10, from: 10 }, 'released')

@@ -92,2 +178,3 @@ expect(response.body.data).toMatchSnapshot()

})
})

@@ -5,2 +5,4 @@ import { SearchkitConfig } from '../src/resolvers/ResultsResolver'

import { setupTestServer, callQuery } from './support/helper'
import nock from 'nock'
import HitsMock from './__mock-data__/HitResolver/Hits.json'

@@ -73,2 +75,37 @@ describe('Summary Resolver', () => {

const scope = nock('http://localhost:9200')
.post('/movies/_search')
.reply((uri, body) => {
expect(body).toMatchInlineSnapshot(`
Object {
"aggs": Object {},
"from": 0,
"post_filter": Object {
"bool": Object {
"must": Array [
Object {
"bool": Object {
"should": Array [
Object {
"term": Object {
"writers.raw": "Jeff Lindsay",
},
},
],
},
},
],
},
},
"size": 10,
"sort": Array [
Object {
"_score": "desc",
},
],
}
`)
return [200, HitsMock]
})
const response = await runQuery(gql)

@@ -75,0 +112,0 @@ expect(response.body.data).toMatchSnapshot()

@@ -1,6 +0,1 @@

import path from 'path'
import { Polly } from '@pollyjs/core'
import FSPersister from '@pollyjs/persister-fs'
import NodeHttpAdapter from '@pollyjs/adapter-node-http'
import { setupPolly } from 'setup-polly-jest'
import express from 'express'

@@ -12,52 +7,2 @@ import request from 'supertest'

Polly.register(NodeHttpAdapter)
Polly.register(FSPersister)
function getDefaultRecordingDir() {
const testPath: string = (global as any).jasmine.testPath
return path.relative(process.cwd(), `${path.dirname(testPath)}/__recordings__`)
}
const mode = process.env.POLLY_MODE || 'replay'
const defaultConfig = {
adapters: ['node-http'],
persister: 'fs',
persisterOptions: {
keepUnusedRequests: false,
fs: {
recordingsDir: getDefaultRecordingDir()
}
},
mode,
recordIfMissing: false,
recordFailedRequests: true,
expiryStrategy: 'warn',
expiresIn: '14d',
// insulate the tests from differences in session data. we use order and
// url to match requests to one another, which we did previously with an
// internal fork of LinkedIn's Sepia VCR. This should be fine for deterministic
// requests, and you can circumvent non-deterministic stuff by manipulating
// things in the Polly Server: https://netflix.github.io/pollyjs/#/server/overview?id=overview
matchRequestsBy: {
headers: false,
body: false
}
}
const context = setupPolly(defaultConfig)
beforeEach(() => {
context.polly.server
.any()
.filter((req) => /^127.0.0.1:[0-9]+$/.test(req.headers.host as string))
.passthrough()
context.polly.server.any().on('request', (req) => {
if (req.url === 'http://localhost:9200/') {
req.url = req.url + 'movies/_search'
}
})
})
export const setupTestServer = (config) => {

@@ -67,3 +12,3 @@ const app = express()

app.use(appServer.setupApolloServer())
agent = request.agent(app)
agent = request(app)
}

@@ -70,0 +15,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc