diff --git a/packages/graphql-yoga/src/server.ts b/packages/graphql-yoga/src/server.ts index 62b4b1f636..ee0857003f 100644 --- a/packages/graphql-yoga/src/server.ts +++ b/packages/graphql-yoga/src/server.ts @@ -94,73 +94,73 @@ export type YogaServerOptions< TServerContext extends Record, TUserContext extends Record, TRootValue, -> = { - /** - * Enable/disable logging or provide a custom logger. - * @default true - */ - logging?: boolean | YogaLogger - /** - * Prevent leaking unexpected errors to the client. We highly recommend enabling this in production. - * If you throw `GraphQLYogaError`/`EnvelopError` within your GraphQL resolvers then that error will be sent back to the client. - * - * You can lean more about this here: - * @see https://graphql-yoga.vercel.app/docs/features/error-masking - * - * Default: `true` - */ - maskedErrors?: boolean | UseMaskedErrorsOpts - /** - * Context - */ - context?: + > = { + /** + * Enable/disable logging or provide a custom logger. + * @default true + */ + logging?: boolean | YogaLogger + /** + * Prevent leaking unexpected errors to the client. We highly recommend enabling this in production. + * If you throw `GraphQLYogaError`/`EnvelopError` within your GraphQL resolvers then that error will be sent back to the client. + * + * You can lean more about this here: + * @see https://graphql-yoga.vercel.app/docs/features/error-masking + * + * Default: `true` + */ + maskedErrors?: boolean | UseMaskedErrorsOpts + /** + * Context + */ + context?: | (( - initialContext: YogaInitialContext & TServerContext, - ) => Promise | TUserContext) + initialContext: YogaInitialContext & TServerContext, + ) => Promise | TUserContext) | Promise | TUserContext - cors?: CORSPluginOptions + cors?: CORSPluginOptions - /** - * GraphQL endpoint - */ - endpoint?: string + /** + * GraphQL endpoint + */ + endpoint?: string - /** - * GraphiQL options - * - * Default: `true` - */ - graphiql?: GraphiQLOptionsOrFactory + /** + * GraphiQL options + * + * Default: `true` + */ + graphiql?: GraphiQLOptionsOrFactory - renderGraphiQL?: (options?: GraphiQLOptions) => PromiseOrValue + renderGraphiQL?: (options?: GraphiQLOptions) => PromiseOrValue - schema?: + schema?: | GraphQLSchema | { - typeDefs: TypeSource - resolvers?: - | IResolvers< - TRootValue, - TUserContext & TServerContext & YogaInitialContext - > - | Array< - IResolvers< - TRootValue, - TUserContext & TServerContext & YogaInitialContext - > - > - } + typeDefs: TypeSource + resolvers?: + | IResolvers< + TRootValue, + TUserContext & TServerContext & YogaInitialContext + > + | Array< + IResolvers< + TRootValue, + TUserContext & TServerContext & YogaInitialContext + > + > + } - parserCache?: boolean | ParserCacheOptions - validationCache?: boolean | ValidationCache - fetchAPI?: FetchAPI - multipart?: boolean - id?: string -} & Partial< - OptionsWithPlugins -> + parserCache?: boolean | ParserCacheOptions + validationCache?: boolean | ValidationCache + fetchAPI?: FetchAPI + multipart?: boolean + id?: string + } & Partial< + OptionsWithPlugins + > export function getDefaultSchema() { return makeExecutableSchema({ @@ -205,7 +205,7 @@ export class YogaServer< TServerContext extends Record, TUserContext extends Record, TRootValue, -> { + > { /** * Instance of envelop */ @@ -237,9 +237,9 @@ export class YogaServer< ? isSchema(options.schema) ? options.schema : makeExecutableSchema({ - typeDefs: options.schema.typeDefs, - resolvers: options.schema.resolvers, - }) + typeDefs: options.schema.typeDefs, + resolvers: options.schema.resolvers, + }) : getDefaultSchema() const logger = options?.logging != null ? options.logging : true @@ -248,11 +248,11 @@ export class YogaServer< ? logger === true ? defaultYogaLogger : { - debug: () => {}, - error: () => {}, - warn: () => {}, - info: () => {}, - } + debug: () => { }, + error: () => { }, + warn: () => { }, + info: () => { }, + } : logger const maskedErrors = options?.maskedErrors ?? true @@ -619,8 +619,8 @@ export function createYoga< TServerContext extends Record = {}, TUserContext extends Record = {}, TRootValue = {}, ->( - options?: YogaServerOptions, + >( + options?: YogaServerOptions, ): YogaServerInstance { const server = new YogaServer( options, diff --git a/yarn.lock b/yarn.lock index 57ea16a4be..830bc6edd3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3361,7 +3361,7 @@ tslib "^2.4.0" value-or-promise "1.0.11" -"@graphql-tools/url-loader@7.13.0", "@graphql-tools/url-loader@^7.0.11", "@graphql-tools/url-loader@^7.9.7": +"@graphql-tools/url-loader@7.13.0": version "7.13.0" resolved "https://registry.yarnpkg.com/@graphql-tools/url-loader/-/url-loader-7.13.0.tgz#f1523ae782b846b0d06dc8488b622ba8ce9a7f33" integrity sha512-hM3yIDij0EqrHrLKNRpFRhQD0tmzt7E5OevOL9O3CLKCcv2Ho4wXQD7gscwVJJdg2Qyr22Pqr/IdtR8QiMScRA== @@ -3403,6 +3403,27 @@ value-or-promise "^1.0.11" ws "^8.3.0" +"@graphql-tools/url-loader@^7.0.11", "@graphql-tools/url-loader@^7.9.7": + version "7.11.0" + resolved "https://registry.yarnpkg.com/@graphql-tools/url-loader/-/url-loader-7.11.0.tgz#c04d4d9f18af58230b589bdd55e81a003e19e5d6" + integrity sha512-c3L/NW9MRkYct4FoQQubTf/VeBhPm0lry2EsgDdcdKmV+lOh3RQ4DAYMH61cTX++MPeQiECYEwCCm68J52xlMg== + dependencies: + "@graphql-tools/delegate" "8.8.0" + "@graphql-tools/utils" "8.8.0" + "@graphql-tools/wrap" "8.5.0" + "@n1ru4l/graphql-live-query" "^0.9.0" + "@types/ws" "^8.0.0" + cross-undici-fetch "^0.4.0" + dset "^3.1.2" + extract-files "^11.0.0" + graphql-ws "^5.4.1" + isomorphic-ws "^4.0.1" + meros "^1.1.4" + sync-fetch "^0.4.0" + tslib "^2.4.0" + value-or-promise "^1.0.11" + ws "^8.3.0" + "@graphql-tools/utils@8.6.9": version "8.6.9" resolved "https://registry.yarnpkg.com/@graphql-tools/utils/-/utils-8.6.9.tgz#fe1b81df29c9418b41b7a1ffe731710b93d3a1fe" @@ -8826,6 +8847,19 @@ cross-undici-fetch@^0.3.5: undici "^5.1.0" web-streams-polyfill "^3.2.0" +cross-undici-fetch@^0.4.0: + version "0.4.14" + resolved "https://registry.yarnpkg.com/cross-undici-fetch/-/cross-undici-fetch-0.4.14.tgz#c841b4fa3cb12b3c3da13dd09f7be45a7bef5ae7" + integrity sha512-CCep44A/baoO8kYJBIR1cRO/tRAk29xzb/tH3O85OtgwZGkL5I0tJZ47ccZdrnAJxrl5tlaYhAOx09fJXMcUqQ== + dependencies: + abort-controller "^3.0.0" + busboy "^1.6.0" + form-data-encoder "^1.7.1" + formdata-node "^4.3.1" + node-fetch "^2.6.7" + undici "5.5.1" + web-streams-polyfill "^3.2.0" + crypt@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" @@ -20604,12 +20638,12 @@ undici@5.0.0: resolved "https://registry.yarnpkg.com/undici/-/undici-5.0.0.tgz#3c1e08c7f0df90c485d5d8dbb0517e11e34f2090" integrity sha512-VhUpiZ3No1DOPPQVQnsDZyfcbTTcHdcgWej1PdFnSvOeJmOVDgiOHkunJmBLfmjt4CqgPQddPVjSWW0dsTs5Yg== -undici@5.5.1, undici@^5.1.0: +undici@5.5.1: version "5.5.1" resolved "https://registry.yarnpkg.com/undici/-/undici-5.5.1.tgz#baaf25844a99eaa0b22e1ef8d205bffe587c8f43" integrity sha512-MEvryPLf18HvlCbLSzCW0U00IMftKGI5udnjrQbC5D4P0Hodwffhv+iGfWuJwg16Y/TK11ZFK8i+BPVW2z/eAw== -undici@^5.8.0: +undici@^5.1.0, undici@^5.8.0: version "5.8.0" resolved "https://registry.yarnpkg.com/undici/-/undici-5.8.0.tgz#dec9a8ccd90e5a1d81d43c0eab6503146d649a4f" integrity sha512-1F7Vtcez5w/LwH2G2tGnFIihuWUlc58YidwLiCv+jR2Z50x0tNXpRRw7eOIJ+GvqCqIkg9SB7NWAJ/T9TLfv8Q==