Skip to content

Usage reporting: fix TS declaration of fieldLevelInstrumentation#6763

Merged
glasser merged 1 commit into
mainfrom
glasser/fix-fieldlevelinstrumentation-type
Aug 4, 2022
Merged

Usage reporting: fix TS declaration of fieldLevelInstrumentation#6763
glasser merged 1 commit into
mainfrom
glasser/fix-fieldlevelinstrumentation-type

Conversation

@glasser

@glasser glasser commented Aug 3, 2022

Copy link
Copy Markdown
Member

Note that the const fieldLevelInstrumentation which this got assigned
to actually already inferred (roughly) the correct type because the type
got merged with a number-returning function from another case.

@glasser glasser requested a review from trevor-scheer August 3, 2022 22:51
@changeset-bot

changeset-bot Bot commented Aug 3, 2022

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: bd9e3f9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify

netlify Bot commented Aug 3, 2022

Copy link
Copy Markdown

Deploy Preview for apollo-server-docs canceled.

Name Link
🔨 Latest commit bd9e3f9
🔍 Latest deploy log https://app.netlify.com/sites/apollo-server-docs/deploys/62eafc17b6e37c00088d8ac3

Note that the `const fieldLevelInstrumentation` which this got assigned
to actually already inferred (roughly) the correct type because the type
got merged with a number-returning function from another case.
@glasser glasser force-pushed the glasser/fix-fieldlevelinstrumentation-type branch from 8642ad0 to bd9e3f9 Compare August 3, 2022 22:52
@codesandbox-ci

codesandbox-ci Bot commented Aug 3, 2022

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit bd9e3f9:

Sandbox Source
Apollo Server Typescript Configuration
Apollo Server Configuration

@trevor-scheer trevor-scheer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should fieldLevelInstrumentation also be assignable to a boolean value? Not a blocker - same functionality can be achieved with 0 and 1 as it currently exists.

@glasser

glasser commented Aug 4, 2022

Copy link
Copy Markdown
Member Author

@trevor-scheer I think my reasoning here was: fieldLevelInstrumentation: 0.01 is not the same thing as fieldLevelInstrumentation: () => 0.01 (it's a shorthand for something more complex, and is what we expect many users to do), so having the number option makes sense. But fieldLevelInstrumentation: false would be identical to fieldLevelInstrumentation: () => false, so why provide two ways to say the same thing.

Arguably we should have only supported a function here, and exported a function like function weightedSample(x: number) { return async () => Math.random() < x ? 1/x : 0 } from the package instead, and the recommended usage would be fieldLevelInstrumentation: weightedSample(0.01). (Maybe if we had had deep imports in AS3 that would have felt better.)

Anyway this PR is just about fixing the types to match the implementation, not about changing the implementation.

@glasser glasser merged commit 6140880 into main Aug 4, 2022
@glasser glasser deleted the glasser/fix-fieldlevelinstrumentation-type branch August 4, 2022 19:08
glasser added a commit that referenced this pull request Aug 4, 2022
Usage reporting: fix TS declaration of fieldLevelInstrumentation

Note that the `const fieldLevelInstrumentation` which this got assigned
to actually already inferred (roughly) the correct type because the type
got merged with a number-returning function from another case.
glasser added a commit that referenced this pull request Aug 4, 2022
Usage reporting: fix TS declaration of fieldLevelInstrumentation

Note that the `const fieldLevelInstrumentation` which this got assigned
to actually already inferred (roughly) the correct type because the type
got merged with a number-returning function from another case.
@github-actions github-actions Bot mentioned this pull request Oct 10, 2022
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants