How to use the graphql-extensions.GraphQLExtensionStack function in graphql-extensions

To help you get started, we’ve selected a few graphql-extensions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apollographql / apollo-server / packages / apollo-server-core / src / runQuery.ts View on Github external
// If custom extension factories were provided, create per-request extension
  // objects.
  const extensions = options.extensions ? options.extensions.map(f => f()) : [];

  // If you're running behind an engineproxy, set these options to turn on
  // tracing and cache-control extensions.
  if (options.tracing) {
    extensions.push(new TracingExtension());
  }
  if (options.cacheControl === true) {
    extensions.push(new CacheControlExtension());
  } else if (options.cacheControl) {
    extensions.push(new CacheControlExtension(options.cacheControl));
  }

  const extensionStack = new GraphQLExtensionStack(extensions);

  // We unconditionally create an extensionStack, even if there are no
  // extensions (so that we don't have to litter the rest of this function with
  // `if (extensionStack)`, but we don't instrument the schema unless there
  // actually are extensions.  We do unconditionally put the stack on the
  // context, because if some other call had extensions and the schema is
  // already instrumented, that's the only way to get a custom fieldResolver to
  // work.
  if (extensions.length > 0) {
    enableGraphQLExtensions(options.schema);
  }
  context._extensionStack = extensionStack;

  const requestDidEnd = extensionStack.requestDidStart({
    // Since the Request interfacess are not the same between node-fetch and
    // typescript's lib dom, we should limit the fields that need to be passed
github apollographql / apollo-server / packages / apollo-server-core / src / requestPipeline.ts View on Github external
enableGraphQLExtensions(config.schema);

    // If custom extension factories were provided, create per-request extension
    // objects.
    const extensions = config.extensions ? config.extensions.map(f => f()) : [];

    if (config.tracing) {
      extensions.push(new TracingExtension());
    }

    if (config.cacheControl) {
      cacheControlExtension = new CacheControlExtension(config.cacheControl);
      extensions.push(cacheControlExtension);
    }

    return new GraphQLExtensionStack(extensions);
  }
github apollographql / apollo-server / packages / apollo-server-core / src / runQuery.ts View on Github external
// If custom extension factories were provided, create per-request extension
  // objects.
  const extensions = options.extensions ? options.extensions.map(f => f()) : [];

  // If you're running behind an engineproxy, set these options to turn on
  // tracing and cache-control extensions.
  if (options.tracing) {
    extensions.push(new TracingExtension());
  }
  if (options.cacheControl === true) {
    extensions.push(new CacheControlExtension());
  } else if (options.cacheControl) {
    extensions.push(new CacheControlExtension(options.cacheControl));
  }

  const extensionStack = new GraphQLExtensionStack(extensions);

  // We unconditionally create an extensionStack, even if there are no
  // extensions (so that we don't have to litter the rest of this function with
  // `if (extensionStack)`, but we don't instrument the schema unless there
  // actually are extensions.  We do unconditionally put the stack on the
  // context, because if some other call had extensions and the schema is
  // already instrumented, that's the only way to get a custom fieldResolver to
  // work.
  if (extensions.length > 0) {
    enableGraphQLExtensions(options.schema);
  }
  context._extensionStack = extensionStack;

  const requestDidEnd = extensionStack.requestDidStart({
    // Since the Request interfacess are not the same between node-fetch and
    // typescript's lib dom, we should limit the fields that need to be passed
github caioreis123 / market2 / backend2 / node_modules / apollo-cache-control / lib / __tests__ / test-utils / helpers.js View on Github external
return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    graphql_extensions_1.enableGraphQLExtensions(schema);
                    cacheControlExtension = new __1.CacheControlExtension(options);
                    return [4 /*yield*/, graphql_1.graphql({
                            schema: schema,
                            source: source,
                            contextValue: {
                                _extensionStack: new graphql_extensions_1.GraphQLExtensionStack([cacheControlExtension])
                            }
                        })];
                case 1:
                    response = _a.sent();
                    expect(response.errors).toBeUndefined();
                    return [2 /*return*/, cacheControlExtension.format()[1].hints];
            }
        });
    });
github caioreis123 / market2 / backend2 / node_modules / apollo-server-core / dist / runQuery.js View on Github external
};
    var debugDefault = process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test';
    var debug = options.debug !== undefined ? options.debug : debugDefault;
    logFunction({ action: LogAction.request, step: LogStep.start });
    var context = options.context || {};
    var extensions = [];
    if (options.tracing) {
        extensions.push(apollo_tracing_1.TracingExtension);
    }
    if (options.cacheControl === true) {
        extensions.push(apollo_cache_control_1.CacheControlExtension);
    }
    else if (options.cacheControl) {
        extensions.push(new apollo_cache_control_1.CacheControlExtension(options.cacheControl));
    }
    var extensionStack = extensions.length > 0 && new graphql_extensions_1.GraphQLExtensionStack(extensions);
    if (extensionStack) {
        context._extensionStack = extensionStack;
        graphql_extensions_1.enableGraphQLExtensions(options.schema);
        extensionStack.requestDidStart();
    }
    var qry = typeof options.query === 'string' ? options.query : graphql_1.print(options.query);
    logFunction({
        action: LogAction.request,
        step: LogStep.status,
        key: 'query',
        data: qry,
    });
    logFunction({
        action: LogAction.request,
        step: LogStep.status,
        key: 'variables',
github yuraxdrumz / Bliz / src / apolloServer / runQuery.js View on Github external
}
  const debugDefault = process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test'
  const debug = options.debug !== undefined ? options.debug : debugDefault

  logFunction({ action: LogAction.request, step: LogStep.start })
  const context = options.context || {}
  let extensions = []
  if (options.tracing) {
    extensions.push(TracingExtension)
  }
  if (options.cacheControl === true) {
    extensions.push(CacheControlExtension)
  } else if (options.cacheControl) {
    extensions.push(new CacheControlExtension(options.cacheControl))
  }
  const extensionStack = extensions.length > 0 && new GraphQLExtensionStack(extensions)

  if (extensionStack) {
    context._extensionStack = extensionStack
    enableGraphQLExtensions(options.schema)

    extensionStack.requestDidStart()
  }
  const qry = typeof options.query === 'string' ? options.query : print(options.query)
  logFunction({
    action: LogAction.request,
    step: LogStep.status,
    key: 'query',
    data: qry
  })
  logFunction({
    action: LogAction.request,
github caioreis123 / market2 / backend2 / node_modules / apollo-server-core / src / runQuery.ts View on Github external
const debug = options.debug !== undefined ? options.debug : debugDefault;

  logFunction({ action: LogAction.request, step: LogStep.start });

  const context = options.context || {};
  let extensions = [];
  if (options.tracing) {
    extensions.push(TracingExtension);
  }
  if (options.cacheControl === true) {
    extensions.push(CacheControlExtension);
  } else if (options.cacheControl) {
    extensions.push(new CacheControlExtension(options.cacheControl));
  }
  const extensionStack =
    extensions.length > 0 && new GraphQLExtensionStack(extensions);

  if (extensionStack) {
    context._extensionStack = extensionStack;
    enableGraphQLExtensions(options.schema);

    extensionStack.requestDidStart();
  }

  const qry =
    typeof options.query === 'string' ? options.query : print(options.query);
  logFunction({
    action: LogAction.request,
    step: LogStep.status,
    key: 'query',
    data: qry,
  });

graphql-extensions

Add extensions to GraphQL servers

MIT
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis

Similar packages