Giter Site home page Giter Site logo

Comments (4)

bizob2828 avatar bizob2828 commented on August 17, 2024 1

@a88zach nice catch. We need to do a better job of keeping these up to date/checking.

from newrelic-node-apollo-server-plugin.

bizob2828 avatar bizob2828 commented on August 17, 2024 1

@a88zach PRs are always welcome. As you can see we aren't writing native typescript so this is always overlooked, I apologize. This is going out shortly has 3.1.1 btw

from newrelic-node-apollo-server-plugin.

workato-integration avatar workato-integration commented on August 17, 2024

https://issues.newrelic.com/browse/NR-145326

from newrelic-node-apollo-server-plugin.

a88zach avatar a88zach commented on August 17, 2024

@bizob2828 thanks for the fix! For a future version, I'd like to suggest a slight enhancement to the typings so that we can correctly type the resolver arguments and request context

export type NRPluginConfig<U = any, V = any> = {
  captureScalars?: boolean;
  captureIntrospectionQueries?: boolean;
  captureServiceDefinitionQueries?: boolean;
  captureHealthCheckQueries?: boolean;
  customResolverAttributes?: (
    resolverArguments: U
  ) => Record<string, string | number | boolean> | null;
  customOperationAttributes?: (
    requestContext: V
  ) => Record<string, string | number | boolean> | null;
  captureFieldMetrics?: boolean;
};

export default function createPlugin<T, U = any, V = any>(
  config?: NRPluginConfig<U, V>
): T;

This would give us strongly typed arguments for the 2 functions

expectType<V3Plugin>(createPlugin<V3Plugin>({}));
expectType<V3Plugin>(
  createPlugin<
    V3Plugin,
    { source: any; args: any; contextValue: { bar: string }; info: any },
    { bar: string }
  >({
    captureHealthCheckQueries: true,
    captureScalars: false,
    captureServiceDefinitionQueries: true,
    captureFieldMetrics: true,
    customOperationAttributes: (ctx) => ({
      attr: ctx.bar,
    }),
    customResolverAttributes: (ctx) => ({ attr: ctx.contextValue.bar }),
  })
);

from newrelic-node-apollo-server-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.