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

Working with Apollo Server 2.0 #44

Closed
dakshshah96 opened this issue May 10, 2018 · 5 comments
Closed

Working with Apollo Server 2.0 #44

dakshshah96 opened this issue May 10, 2018 · 5 comments

Comments

@dakshshah96
Copy link

How would I use apollo-errors with Apollo Server 2.0? Example:

const { ApolloServer, gql } = require('apollo-server');

// Construct a schema, using GraphQL schema language
const typeDefs = gql`
  type Query {
    announcement: String
  }
`;

// Provide resolver functions for your schema fields
const resolvers = {
  Query: {
    announcement: () =>
      `Say hello to the new Apollo Server! A production ready GraphQL server with an incredible getting started experience.`
  }
};

const server = new ApolloServer({ typeDefs, resolvers });

server.listen().then(({ url }) => {
  console.log(`🚀 Server ready at ${url}`);
});
@theGlenn
Copy link

Apollo 2.0 already implements a built error handling mechanism. You can check it at: https://www.apollographql.com/docs/apollo-server/v2/features/errors.html

@thebigredgeek
Copy link
Owner

Yep true but it's super basic!

@theGlenn
Copy link

theGlenn commented Jun 7, 2018

@dakshshah96 @thebigredgeek , with Apollo's new system, error generation might be the way to go. A simple script that generates Apollo error classes from a JSON definition file.

@thebigredgeek
Copy link
Owner

That sounds neat! Down to explore it

@theGlenn
Copy link

theGlenn commented Jun 8, 2018

I got inspired a little bit and started working on this project here it's called apollo-prophecy not yet production ready tho.
Not on npm yet so @dakshshah96 you can clone and run it locally if you want.

I created an issue to make it work with third party Apollo libraries like apollo-errors
theGlenn/apollo-prophecy#2

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

3 participants