Skip to content

Commit

Permalink
Drop bundles (#6222)
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan authored Oct 27, 2023
1 parent f4c9ab5 commit 5c6a8f7
Show file tree
Hide file tree
Showing 15 changed files with 15 additions and 262 deletions.
11 changes: 11 additions & 0 deletions .changeset/fast-cars-perform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@graphql-mesh/json-schema': minor
'@omnigraph/json-schema': minor
'@graphql-mesh/openapi': minor
'@graphql-mesh/raml': minor
'@omnigraph/raml': minor
'@graphql-mesh/types': minor
---

BREAKING: Drop bundles, you can use the SDL output from the artifacts later as a `source` of the
handler
22 changes: 0 additions & 22 deletions packages/handlers/json-schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import {
} from '@graphql-mesh/types';
import { readFileOrUrl } from '@graphql-mesh/utils';
import {
getGraphQLSchemaFromBundle,
JSONSchemaLoaderBundle,
loadNonExecutableGraphQLSchemaFromJSONSchemas,
processDirectives,
} from '@omnigraph/json-schema';
Expand Down Expand Up @@ -67,26 +65,6 @@ export default class JsonSchemaHandler implements MeshHandler {
});
}
return this.schemaWithAnnotationsProxy.getWithSet(async () => {
if (this.config.bundlePath) {
this.logger.info(`Fetching JSON Schema bundle`);
const bundle = await readFileOrUrl<JSONSchemaLoaderBundle>(this.config.bundlePath, {
allowUnknownExtensions: true,
cwd: this.baseDir,
fetch: this.fetchFn,
importFn: this.importFn,
logger: this.logger,
headers: this.config.bundleHeaders,
});
return getGraphQLSchemaFromBundle(bundle, {
cwd: this.baseDir,
logger: this.logger,
fetch: this.fetchFn,
endpoint: this.config.endpoint,
operationHeaders: this.config.operationHeaders,
queryParams: this.config.queryParams,
queryStringOptions: this.config.queryStringOptions,
});
}
this.logger.info(`Generating GraphQL schema from JSON Schemas`);
return loadNonExecutableGraphQLSchemaFromJSONSchemas(this.name, {
...this.config,
Expand Down
12 changes: 0 additions & 12 deletions packages/handlers/json-schema/yaml-config.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ enum QueryStringArrayFormat {
}

type JsonSchemaHandler @md {
"""
Path to the bundle file
"""
source: String
endpoint: String
operationHeaders: JSON
Expand All @@ -59,15 +56,6 @@ type JsonSchemaHandler @md {
queryParams: Any
queryStringOptions: QueryStringOptions

"""
Will be removed later
"""
bundlePath: String
"""
Will be removed later
"""
bundleHeaders: JSON

"""
Timeout for the HTTP request in milliseconds
"""
Expand Down
9 changes: 0 additions & 9 deletions packages/handlers/openapi/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default class OpenAPIHandler implements MeshHandler {
private name: string;
private config: YamlConfig.OpenapiHandler;
private schemaWithAnnotationsProxy: StoreProxy<GraphQLSchema>;
private bundleProxy: StoreProxy<any>;
private baseDir: string;
private logger: Logger;
private fetchFn: MeshFetch;
Expand All @@ -41,10 +40,6 @@ export default class OpenAPIHandler implements MeshHandler {
'schemaWithAnnotations',
PredefinedProxyOptions.GraphQLSchemaWithDiffing,
);
this.bundleProxy = store.proxy(
'jsonSchemaBundle',
PredefinedProxyOptions.JsonWithoutValidation,
);
this.pubsub = pubsub;
this.importFn = importFn;
this.logger = logger;
Expand Down Expand Up @@ -81,11 +76,7 @@ export default class OpenAPIHandler implements MeshHandler {
}),
),
pubsub: this.pubsub,
bundle: this.config.bundle,
});
if (this.config.bundle) {
await this.bundleProxy.set(schema.extensions!.bundle);
}
return schema;
});
}
Expand Down
2 changes: 0 additions & 2 deletions packages/handlers/openapi/yaml-config.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ type OpenapiHandler @md {
Timeout for the HTTP request in milliseconds
"""
timeout: Int

bundle: Boolean
}

enum FallbackFormat {
Expand Down
9 changes: 0 additions & 9 deletions packages/handlers/raml/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default class RAMLHandler implements MeshHandler {
private name: string;
private config: YamlConfig.RAMLHandler;
private schemaWithAnnotationsProxy: StoreProxy<GraphQLSchema>;
private bundleProxy: StoreProxy<any>;
private baseDir: string;
private logger: Logger;
private fetchFn: MeshFetch;
Expand All @@ -40,10 +39,6 @@ export default class RAMLHandler implements MeshHandler {
'schemaWithAnnotations',
PredefinedProxyOptions.GraphQLSchemaWithDiffing,
);
this.bundleProxy = store.proxy(
'jsonSchemaBundle',
PredefinedProxyOptions.JsonWithoutValidation,
);
this.pubsub = pubsub;
this.importFn = importFn;
this.logger = logger;
Expand Down Expand Up @@ -80,11 +75,7 @@ export default class RAMLHandler implements MeshHandler {
}),
),
pubsub: this.pubsub,
bundle: this.config.bundle,
});
if (this.config.bundle) {
await this.bundleProxy.set(schema.extensions!.bundle);
}
return schema;
});
}
Expand Down
1 change: 0 additions & 1 deletion packages/handlers/raml/yaml-config.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ type RAMLHandler {
ignoreErrorResponses: Boolean
selectQueryOrMutationField: [RAMLSelectQueryOrMutationFieldConfig]
queryParams: Any
bundle: Boolean

"""
Timeout for the HTTP request in milliseconds
Expand Down
125 changes: 0 additions & 125 deletions packages/loaders/json-schema/src/bundle.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/loaders/json-schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ export * from './getDereferencedJSONSchemaFromOperations.js';
export * from './getGraphQLSchemaFromDereferencedJSONSchema.js';
export * from './types.js';
export { processDirectives } from './directives.js';
export * from './bundle.js';
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { DefaultLogger } from '@graphql-mesh/utils';
import { fetch } from '@whatwg-node/fetch';
import { createBundleFromDereferencedSchema } from './bundle.js';
import { processDirectives } from './directives.js';
import { getDereferencedJSONSchemaFromOperations } from './getDereferencedJSONSchemaFromOperations.js';
import { getGraphQLSchemaFromDereferencedJSONSchema } from './getGraphQLSchemaFromDereferencedJSONSchema.js';
Expand All @@ -23,7 +22,7 @@ export async function loadNonExecutableGraphQLSchemaFromJSONSchemas(
schemaHeaders: options.schemaHeaders,
ignoreErrorResponses: options.ignoreErrorResponses,
});
const schema = await getGraphQLSchemaFromDereferencedJSONSchema(name, {
return getGraphQLSchemaFromDereferencedJSONSchema(name, {
fullyDeferencedSchema,
logger: options.logger,
operations: options.operations,
Expand All @@ -32,20 +31,6 @@ export async function loadNonExecutableGraphQLSchemaFromJSONSchemas(
queryParams: options.queryParams,
queryStringOptions: options.queryStringOptions,
});
if (options.bundle) {
schema.extensions = schema.extensions || {};
Object.defineProperty(schema.extensions, 'bundle', {
value: await createBundleFromDereferencedSchema(name, {
dereferencedSchema: fullyDeferencedSchema,
endpoint: options.endpoint,
operations: options.operations,
operationHeaders:
typeof options.operationHeaders === 'object' ? options.operationHeaders : {},
logger: options.logger,
}),
});
}
return schema;
}

export async function loadGraphQLSchemaFromJSONSchemas(
Expand Down
6 changes: 0 additions & 6 deletions packages/loaders/raml/src/loadGraphQLSchemaFromRAML.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import {
import { getJSONSchemaOptionsFromRAMLOptions } from './getJSONSchemaOptionsFromRAMLOptions.js';
import { RAMLLoaderOptions } from './types.js';

/**
* Creates a local GraphQLSchema instance from a RAML API Document.
* Everytime this function is called, the RAML file and its dependencies will be resolved on runtime.
* If you want to avoid this, use `createBundle` function to create a bundle once and save it to a storage
* then load it with `loadGraphQLSchemaFromBundle`.
*/
export async function loadGraphQLSchemaFromRAML(name: string, options: RAMLLoaderOptions) {
const extraJSONSchemaOptions = await getJSONSchemaOptionsFromRAMLOptions(options);
return loadGraphQLSchemaFromJSONSchemas(name, {
Expand Down
Loading

0 comments on commit 5c6a8f7

Please sign in to comment.