Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v3] Persisted Operations ExtractPersistedOperationId type #2045

Open
Tracked by #2700 ...
n1ru4l opened this issue Nov 8, 2022 · 0 comments
Open
Tracked by #2700 ...

[v3] Persisted Operations ExtractPersistedOperationId type #2045

n1ru4l opened this issue Nov 8, 2022 · 0 comments
Milestone

Comments

@n1ru4l
Copy link
Collaborator

n1ru4l commented Nov 8, 2022

Maybe the following function:

export declare type ExtractPersistedOperationId = (params: GraphQLParams) => null | string;

export type ExtractPersistedOperationId = (
params: GraphQLParams,
) => null | string

Should rather be typed:

export type ExtractPersistedOperationId = (
  params: Record<string, unknown>
) => null | string

This would force people to do proper type narrowing:

const yoga = createYoga({
  plugins: [
    usePersistedOperations({
      extractPersistedOperationId(payload) {
        if (typeof payload.doc_id === 'string') {
          return payload.doc_id
        }
        return null
      }
      getPersistedOperation(key: string) {
        return persistedOperations[key]
      },
    }),
  ],
})
@n1ru4l n1ru4l added this to the v3 milestone Nov 8, 2022
@theguild-bot theguild-bot mentioned this issue Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant