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

update graphql to v16 #3564

Merged
merged 6 commits into from
Sep 13, 2024
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
2 changes: 1 addition & 1 deletion e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"devDependencies": {
"@terascope/types": "^1.1.0",
"bunyan": "^1.8.15",
"elasticsearch-store": "^1.1.0",
"elasticsearch-store": "^1.1.1",
"fs-extra": "^11.2.0",
"ms": "^2.1.3",
"nanoid": "^3.3.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/data-mate/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/data-mate",
"displayName": "Data-Mate",
"version": "1.1.0",
"version": "1.1.1",
"description": "Library of data validations/transformations",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/data-mate#readme",
"repository": {
Expand Down Expand Up @@ -30,7 +30,7 @@
"test:watch": "ts-scripts test --watch . --"
},
"dependencies": {
"@terascope/data-types": "^1.1.0",
"@terascope/data-types": "^1.1.1",
"@terascope/types": "^1.1.0",
"@terascope/utils": "^1.1.0",
"@types/validator": "^13.11.10",
Expand Down
4 changes: 2 additions & 2 deletions packages/data-types/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/data-types",
"displayName": "Data Types",
"version": "1.1.0",
"version": "1.1.1",
"description": "A library for defining the data structures and mapping",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/data-types#readme",
"bugs": {
Expand Down Expand Up @@ -29,7 +29,7 @@
"dependencies": {
"@terascope/types": "^1.1.0",
"@terascope/utils": "^1.1.0",
"graphql": "^14.7.0",
"graphql": "^16.9.0",
"lodash": "^4.17.21",
"yargs": "^17.7.2"
},
Expand Down
8 changes: 4 additions & 4 deletions packages/data-types/src/data-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ESTypeMappings, ReadonlyDataTypeFields, xLuceneTypeConfig
} from '@terascope/types';
import lodash from 'lodash';
import { formatSchema, formatGQLComment } from './graphql-helper.js';
import { formatSchema, formatGQLDescription } from './graphql-helper.js';
import * as i from './interfaces.js';
import BaseType from './types/base-type.js';
import * as utils from './utils.js';
Expand Down Expand Up @@ -232,13 +232,13 @@ export class DataType {

if (references.length) {
baseProperties.push(utils.joinStrings(
formatGQLComment('references and virtual fields'),
formatGQLDescription('references and virtual fields'),
references
));
}

const baseType = utils.joinStrings(
formatGQLComment(description),
formatGQLDescription(description),
`type ${typeName} {
${utils.joinStrings(baseProperties)}
}`
Expand All @@ -248,7 +248,7 @@ export class DataType {

if (createInputType) {
inputType = utils.joinStrings(
formatGQLComment(description, `Input for ${typeName}`),
formatGQLDescription(description, `Input for ${typeName}`),
`input ${inputName} {
${utils.joinStrings(inputProperties)}
}`
Expand Down
22 changes: 11 additions & 11 deletions packages/data-types/src/graphql-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ import { trim } from '@terascope/utils';
import { buildSchema, printSchema } from 'graphql/utilities/index.js';

export function formatSchema(schemaStr: string, removeScalars = false): string {
const schema = buildSchema(schemaStr, {
commentDescriptions: true,
});
const result = printSchema(schema, {
commentDescriptions: true
});
const schema = buildSchema(schemaStr);
const result = printSchema(schema!);

if (removeScalars) {
return result.replace(/\s*scalar \w+/g, '');
}
return result;
}

export function formatGQLComment(desc?: string, prefix?: string): string {
export function formatGQLDescription(desc?: string, prefix?: string): string {
let description = trim(desc);
if (prefix) {
description = description ? `${prefix} - ${description}` : prefix;
}
if (!description) return '';

return description
const trimmedLines = description
.split('\n')
.map((str) => trim(str).replace(/^#/, '').trim())
.map((str) => str.trim())
.filter(Boolean)
.map((str) => `# ${str}`)
.join('\n');
.map((str) => `${str}`);

if (trimmedLines.length > 1) {
return `"""${trimmedLines.join('\n')}"""`;
}
return `""" ${trimmedLines[0]} """`;
}
4 changes: 2 additions & 2 deletions packages/data-types/src/types/base-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
} from '@terascope/types';
import { castArray } from '@terascope/utils';
import { GraphQLType, TypeESMapping } from '../interfaces.js';
import { formatGQLComment } from '../graphql-helper.js';
import { formatGQLDescription } from '../graphql-helper.js';

export interface IBaseType {
new(field: string, config: DataTypeFieldConfig): BaseType;
Expand Down Expand Up @@ -73,5 +73,5 @@ function makeCustomTypes(customType?: string|(string[])): string[] {

export function formatGQLType(type: string, desc?: string):string {
if (!desc) return type;
return `${formatGQLComment(desc)}\n${type}`;
return `${formatGQLDescription(desc)}\n${type}`;
}
40 changes: 22 additions & 18 deletions packages/data-types/test/data-type-graphql-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,24 @@ describe('DataType (graphql)', () => {
lon: String!
}

# My test data type
# some extra desc
"""
My test data type
some extra desc
"""
type myType {
date: String
# example obj test
" example obj test "
example_obj: JSONObject
# # hello
"""
## hello
# test
"""
hello: String
# ip test
" ip test "
ip: String
# location test
" location test "
location: DTGeoPointV1
# some number test
" some number test "
someNum: Float
}
`);
Expand Down Expand Up @@ -77,12 +81,12 @@ describe('DataType (graphql)', () => {
foo: String
}

# nested field test description
""" nested field test description """
type ObjType {
example: DTObjTypeExampleV1
}

# Input for ObjType - nested field test description
""" Input for ObjType - nested field test description """
input ObjTypeInput {
example: DTObjTypeExampleInputV1
}
Expand Down Expand Up @@ -135,7 +139,7 @@ describe('DataType (graphql)', () => {

expect(() => {
new DataType(typeConfig).toGraphQL();
}).toThrowError('No typeName was specified to create the graphql type representing this data structure');
}).toThrow('No typeName was specified to create the graphql type representing this data structure');
});
});

Expand Down Expand Up @@ -272,7 +276,7 @@ describe('DataType (graphql)', () => {
someNum: Float
}

# Input for first_type
""" Input for first_type """
input first_type_input {
date: String
hello: String
Expand All @@ -289,7 +293,7 @@ describe('DataType (graphql)', () => {
otherLocation: [[DTGeoBoundaryV1]]
}

# Input for second_type
""" Input for second_type """
input second_type_input {
bool: Boolean
foo: DT_second_type_foo_input_V1
Expand Down Expand Up @@ -330,7 +334,7 @@ describe('DataType (graphql)', () => {
name: String
}

# Input for TestRecord
""" Input for TestRecord """
input TestRecordInput {
description: String
name: String
Expand Down Expand Up @@ -397,7 +401,7 @@ describe('DataType (graphql)', () => {

expect(() => {
DataType.mergeGraphQLDataTypes(types, { removeScalars: true });
}).toThrowError(/Unable to process duplicate DataType "Hello"/);
}).toThrow(/Unable to process duplicate DataType "Hello"/);
});

it('should throw when given a type without a type name', () => {
Expand All @@ -414,7 +418,7 @@ describe('DataType (graphql)', () => {

expect(() => {
DataType.mergeGraphQLDataTypes(types);
}).toThrowError(/Unable to process DataType with missing type name/);
}).toThrow(/Unable to process DataType with missing type name/);
});

it('should be able to combine mulitple types together with references', () => {
Expand Down Expand Up @@ -469,7 +473,7 @@ describe('DataType (graphql)', () => {

type Info {
id: String
# references and virtual fields
""" references and virtual fields """
info(query: String): Info
}

Expand All @@ -479,7 +483,7 @@ describe('DataType (graphql)', () => {
ip: String
location: DTGeoPointV1
long_number: Float
# references and virtual fields
""" references and virtual fields """
info(query: String): Info
num_parents: Int
}
Expand All @@ -489,7 +493,7 @@ describe('DataType (graphql)', () => {
obj: JSONObject
other_location: DTGeoPointV1
some_date: String
# references and virtual fields
""" references and virtual fields """
info(query: String): Info
children: ChildType
}
Expand Down
2 changes: 1 addition & 1 deletion packages/elasticsearch-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@opensearch-project/opensearch": "^1.2.0",
"@types/elasticsearch": "^5.0.43",
"elasticsearch": "^15.4.1",
"elasticsearch-store": "^1.1.0",
"elasticsearch-store": "^1.1.1",
"elasticsearch6": "npm:@elastic/elasticsearch@^6.7.0",
"elasticsearch7": "npm:@elastic/elasticsearch@^7.0.0",
"elasticsearch8": "npm:@elastic/elasticsearch@^8.0.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/elasticsearch-store/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "elasticsearch-store",
"displayName": "Elasticsearch Store",
"version": "1.1.0",
"version": "1.1.1",
"description": "An API for managing an elasticsearch index, with versioning and migration support.",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/elasticsearch-store#readme",
"bugs": {
Expand Down Expand Up @@ -30,8 +30,8 @@
"test:watch": "ts-scripts test --watch . --"
},
"dependencies": {
"@terascope/data-mate": "^1.1.0",
"@terascope/data-types": "^1.1.0",
"@terascope/data-mate": "^1.1.1",
"@terascope/data-types": "^1.1.1",
"@terascope/types": "^1.1.0",
"@terascope/utils": "^1.1.0",
"ajv": "^6.12.6",
Expand Down
4 changes: 2 additions & 2 deletions packages/terafoundation/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "terafoundation",
"displayName": "Terafoundation",
"version": "1.3.0",
"version": "1.3.1",
"description": "A Clustering and Foundation tool for Terascope Tools",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/terafoundation#readme",
"bugs": {
Expand Down Expand Up @@ -37,7 +37,7 @@
"convict-format-with-moment": "^6.2.0",
"convict-format-with-validator": "^6.2.0",
"elasticsearch": "^15.4.1",
"elasticsearch-store": "^1.1.0",
"elasticsearch-store": "^1.1.1",
"express": "^4.20.0",
"js-yaml": "^4.1.0",
"nanoid": "^3.3.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/teraslice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"semver": "^7.6.3",
"socket.io": "^1.7.4",
"socket.io-client": "^1.7.4",
"terafoundation": "^1.3.0",
"terafoundation": "^1.3.1",
"uuid": "^9.0.1"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/ts-transforms/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ts-transforms",
"displayName": "TS Transforms",
"version": "1.1.0",
"version": "1.1.1",
"description": "An ETL framework built upon xlucene-evaluator",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/ts-transforms#readme",
"bugs": {
Expand Down Expand Up @@ -36,7 +36,7 @@
"test:watch": "ts-scripts test --watch . --"
},
"dependencies": {
"@terascope/data-mate": "^1.1.0",
"@terascope/data-mate": "^1.1.1",
"@terascope/types": "^1.1.0",
"@terascope/utils": "^1.1.0",
"awesome-phonenumber": "^2.70.0",
Expand Down
Loading
Loading