-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basic apollo-engine-reporting integration
- Loading branch information
Showing
7 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const { ApolloServer, gql } = require('./packages/apollo-server'); | ||
|
||
// This is a (sample) collection of books we'll be able to query | ||
// the GraphQL server for. A more complete example might fetch | ||
// from an existing data source like a REST API or database. | ||
const books = [ | ||
{ | ||
title: 'Harry Potter and the Chamber of Secrets', | ||
author: 'J.K. Rowling', | ||
}, | ||
{ | ||
title: 'Jurassic Park', | ||
author: 'Michael Crichton', | ||
}, | ||
]; | ||
|
||
// Type definitions define the "shape" of your data and specify | ||
// which ways the data can be fetched from the GraphQL server. | ||
const typeDefs = gql` | ||
# Comments in GraphQL are defined with the hash (#) symbol. | ||
# This "Book" type can be used in other type declarations. | ||
type Book { | ||
title: String | ||
author: String | ||
} | ||
# The "Query" type is the root of all GraphQL queries. | ||
# (A "Mutation" type will be covered later on.) | ||
type Query { | ||
books: [Book] | ||
} | ||
`; | ||
|
||
// Resolvers define the technique for fetching the types in the | ||
// schema. We'll retrieve books from the "books" array above. | ||
const resolvers = { | ||
Query: { | ||
books: () => books, | ||
}, | ||
}; | ||
|
||
// In the most basic sense, the ApolloServer can be started | ||
// by passing type definitions (typeDefs) and the resolvers | ||
// responsible for fetching the data for those types. | ||
const server = new ApolloServer({ | ||
typeDefs, | ||
resolvers, | ||
engine: { | ||
apiKey: 'service:glasser-test-aer:hSAgHbxMg56FPgCRUDVznw', | ||
endpointUrl: 'https://engine-staging-report.apollodata.com', | ||
debugPrintReports: true, | ||
}, | ||
}); | ||
|
||
// This `listen` method launches a web-server. Existing apps | ||
// can utilize middleware options, which we'll discuss later. | ||
server.listen().then(({ url }) => { | ||
console.log(`🚀 Server ready at ${url}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters