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

graphql-constraint-directive library using EOL package for apollo-server-errors #269

Open
fdang-godaddy opened this issue Nov 25, 2024 · 1 comment

Comments

@fdang-godaddy
Copy link

fdang-godaddy commented Nov 25, 2024

Code below is using an end of life package and needs updated
Package: apollo-server-errors
Links: https://www.npmjs.com/package/apollo-server-errors, https://www.apollographql.com/docs/apollo-server/migration#packages-merged-into-apolloserver

Line of code

const { UserInputError } = require('apollo-server-errors')

function createApolloQueryValidationPlugin ({ schema }, options = {}) {
  return {
    async requestDidStart () {
      return ({
        async didResolveOperation ({ request, document }) {
          const query = request.operationName
            ? separateOperations(document)[request.operationName]
            : document

          const errors = validateQuery(
            schema,
            query,
            request.variables,
            request.operationName,
            options
          )
          if (errors.length > 0) {
            throw errors.map(err => {
              const { UserInputError } = require('apollo-server-errors')
              return new UserInputError(err.message, { field: err.fieldName, context: err.context })
            })
          }
        }
      })
    }
  }
}
@aHenryJard
Copy link

I think that this has been fixed already by #243

Any chance to get a release that contains this fix @confuser ?

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

2 participants