@mercuriusjs/federation
Advanced tools
Comparing version 0.1.0 to 1.0.0
import { GraphQLSchema } from 'graphql' | ||
import { FastifyInstance } from 'fastify' | ||
import { MercuriusOptions } from 'mercurius' | ||
import { | ||
DocumentNode | ||
} from 'graphql/language/ast'; | ||
@@ -10,3 +13,3 @@ export interface buildFederationSchemaOptions { | ||
export type MercuriusFederationOptions = Omit<MercuriusOptions, 'schema'> & { | ||
schema: string | ||
schema: string | DocumentNode | Array<DocumentNode> | ||
} | ||
@@ -23,4 +26,4 @@ | ||
export declare const buildFederationSchema: ( | ||
schema: string, | ||
schema: string | DocumentNode | Array<DocumentNode>, | ||
opts?: buildFederationSchemaOptions | ||
) => GraphQLSchema |
@@ -42,2 +42,4 @@ /* | ||
const compositionRules = require('./compositionRules') | ||
const mergeDocumentNode = require('./mergeDocumentNode') | ||
const { | ||
@@ -105,3 +107,3 @@ MER_ERR_GQL_INVALID_SCHEMA, | ||
for (const definition of schemaDefinitions) { | ||
if (definition.kind === 'SchemaDefinition') { | ||
if (definition.kind === 'SchemaDefinition' || definition.kind === 'SchemaExtension') { | ||
continue | ||
@@ -248,3 +250,3 @@ } | ||
...queryFields._service, | ||
resolve: () => ({ sdl: originalSchemaSDL }) | ||
resolve: () => ({ sdl: typeof originalSchemaSDL === 'string' ? originalSchemaSDL : originalSchemaSDL.loc.source.body }) | ||
} | ||
@@ -293,2 +295,8 @@ | ||
function buildFederationSchema (schema, { isGateway } = {}) { | ||
if (Array.isArray(schema)) { | ||
schema = mergeDocumentNode(schema) | ||
} else if (typeof schema === 'object') { | ||
schema = mergeDocumentNode([schema]) | ||
} | ||
let federationSchema = new GraphQLSchema({ | ||
@@ -304,3 +312,3 @@ query: undefined | ||
const parsedOriginalSchema = parse(schema) | ||
const parsedOriginalSchema = typeof schema === 'string' ? parse(schema) : schema | ||
const { typeStubs, extensions, definitions } = getStubTypes( | ||
@@ -307,0 +315,0 @@ parsedOriginalSchema.definitions, |
{ | ||
"name": "@mercuriusjs/federation", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "A plugin for mercurius federation", | ||
@@ -39,7 +39,11 @@ "main": "index.js", | ||
"@commitlint/config-conventional": "^17.2.0", | ||
"@typescript-eslint/eslint-plugin": "^5.42.0", | ||
"@typescript-eslint/parser": "^5.42.0", | ||
"@graphql-tools/merge": "^8.3.12", | ||
"@graphql-tools/schema": "^9.0.10", | ||
"@graphql-tools/utils": "^9.1.1", | ||
"@typescript-eslint/eslint-plugin": "^5.43.0", | ||
"@typescript-eslint/parser": "^5.43.0", | ||
"fastify": "^4.9.2", | ||
"graphql-tag": "^2.12.6", | ||
"graphql-ws": "^5.11.2", | ||
"husky": "^8.0.1", | ||
"husky": "^8.0.2", | ||
"lint-staged": "^13.0.3", | ||
@@ -49,4 +53,4 @@ "mqemitter": "^5.0.0", | ||
"standard": "^17.0.0", | ||
"tap": "^16.3.0", | ||
"tsd": "^0.24.1", | ||
"tap": "16.3.4", | ||
"tsd": "^0.25.0", | ||
"ws": "^8.11.0" | ||
@@ -53,0 +57,0 @@ }, |
@@ -108,3 +108,3 @@ # @mercuriusjs/federation | ||
Uses the same [options](https://mercurius.dev/#/docs/api/options?id=plugin-options) of `mercurius` but | ||
it requires a `string` for `schema` attribute. | ||
it requires a `string`, `DocumentNode` or an Array of `DocumentNode` for `schema` attribute. | ||
@@ -117,4 +117,4 @@ ### buildFederationSchema | ||
- `schema` string: the source schema | ||
- `schema` string | DocumentNode | Array<DocumentNode>: the source schema | ||
- `opts` object: | ||
- `isGateway` boolean: If enabled create a schema compatible with the `gateway`, Default 'false' |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
20051
10
450
0
18