Skip to content
7 changes: 7 additions & 0 deletions modules/server/src/network/setup/fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ export const getFieldTypes = (
return fieldTypes;
};

/**
*
* @param nodeConfigs
* @param supportedTypes
* @returns unique fields
*/
export const getAllFieldTypes = (
nodeConfigs: NodeConfig[],
supportedTypes: SupportedAggregation[],
Expand All @@ -72,6 +78,7 @@ export const getAllFieldTypes = (
const allSupportedAggregations = nodeFieldTypes.flatMap(
(fieldType) => fieldType.supportedAggregations,
);

/*
* Returns unique fields
* eg. if NodeA and NodeB both have `analysis__analysis__id`, only include it once
Expand Down
25 changes: 19 additions & 6 deletions modules/server/src/network/tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
// @ts-nocheck
// graphql types have readonly modifiers all the way down

import { buildSchema } from 'graphql';
import { createNetworkAggregationTypeDefs } from '../schema';
/*
* PLEASE NOTE:
* Old tests not used anymore
* Leaving in code base for now because the tests themselves are worthwhile to write, not currently in scope
* Disabled using the "xdescribe" method
*/

import { mergeTypeDefs, mergeTypeDefs } from '@graphql-tools/merge';
import { makeExecutableSchema, mergeSchemas } from '@graphql-tools/schema';
import { buildSchema, printType } from 'graphql';
import { createNetworkAggregationTypeDefs } from '../typeDefs/aggregations';
import {
typeDefsA,
typeDefsB,
Expand All @@ -14,12 +23,16 @@ import {
} from './fixtures';
import { isFieldDefined, isTypeDefined } from './utils';

describe('network aggregation', () => {
xdescribe('network aggregation', () => {
test('it should have defined GQL Object types', () => {
const networkSchemas = [buildSchema(typeDefsA), buildSchema(typeDefsB)];

const actualOutput = createNetworkAggregationTypeDefs(networkSchemas);
const typeDefs = actualOutput.definitions;
console.log('ns', networkSchemas);
const s = mergeTypeDefs([buildSchema(typeDefsA), buildSchema(typeDefsB)]);
console.log('typedefs', s);
const typeDefs = createNetworkAggregationTypeDefs(networkSchemas);
//const x = mergeTypeDefs([typeDefs, typeDefs]);
// const typeDefs = actualOutput.definitions;
console.log(typeDefs._typeMap);

expect(isTypeDefined(typeDefs, 'Aggs')).toEqual(true);
expect(isTypeDefined(typeDefs, 'Donor')).toEqual(true);
Expand Down
7 changes: 6 additions & 1 deletion modules/server/src/network/tests/query.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ describe('gql query creation', () => {
// whitespace doesn't matter in the gql string, there are spaces for readability in code
.replaceAll(' ', '');

expect(result).toEqual('{testFile{hits{total}aggregations{donors{buckets{bucket_count}}}}}');
const expected =
'query nodeQuery($filters: JSON, $aggregations_filter_themselves: Boolean, $include_missing: Boolean) {testFile { hits { total } aggregations(filters:$filters,aggregations_filter_themselves:$aggregations_filter_themselves,include_missing:$include_missing){donors{buckets{bucket_count}}} }}'.replaceAll(
' ',
'',
);
expect(result).toEqual(expected);
});
});