Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
fix: Apply changes to new content from master
Browse files Browse the repository at this point in the history
  • Loading branch information
wtrocki committed Jan 29, 2019
1 parent 9428d9a commit fd22e3c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 38 deletions.
8 changes: 3 additions & 5 deletions examples/conflicts/server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const express = require('express')
const { makeExecutableSchema } = require('graphql-tools')
const queries = require("./queries")
const queries = require('./queries')
const { VoyagerServer, gql } = require('@aerogear/voyager-server')

const { conflictHandler } = require('@aerogear/voyager-conflicts')
Expand Down Expand Up @@ -75,8 +74,6 @@ const resolvers = {
}
}

const schema = makeExecutableSchema({ typeDefs, resolvers })

// The context is a function or object that can add some extra data
// That will be available via the `context` argument the resolver functions
const context = ({ req }) => {
Expand All @@ -87,14 +84,15 @@ const context = ({ req }) => {

// Initialize the voyager server with our schema and context
const server = VoyagerServer({
typeDefs,
resolvers,
playground: {
tabs: [{
endpoint: '/graphql',
variables: {},
query: queries
}]
},
schema,
context
})

Expand Down
1 change: 1 addition & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"author": "",
"license": "Apache-2.0",
"dependencies": {
"@aerogear/voyager-tools": "^0.3.0",
"@aerogear/voyager-audit": "^0.3.0",
"@aerogear/voyager-conflicts": "^0.3.0",
"@aerogear/voyager-keycloak": "^0.3.0",
Expand Down
55 changes: 22 additions & 33 deletions examples/restapi/server.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const express = require("express");
const { makeExecutableSchema } = require("graphql-tools");
const queries = require("./queries");
const axios = require("axios");
const express = require('express')
const queries = require('./queries')
const axios = require('axios')
const {
ApolloVoyagerServer,
VoyagerServer,
gql
} = require("../../packages/apollo-voyager-server");
} = require('@aerogear/voyager-server')

// Types
const typeDefs = gql`
Expand All @@ -18,7 +17,7 @@ const typeDefs = gql`
type Query {
getCarModels(brand: String!): [ModelInfo]
}
`;
`

// Resolver functions. This is our business logic
const resolvers = {
Expand All @@ -28,42 +27,32 @@ const resolvers = {
const response = await axios.get(
`https://vpic.nhtsa.dot.gov/api/vehicles/getmodelsformake/${args.brand}`,
{
responseType: "json",
params: { format: "json" }
responseType: 'json',
params: { format: 'json' }
}
);
const { data } = response;
return data.Results;
)
const { data } = response
return data.Results
}
}
};
}

const schema = makeExecutableSchema({ typeDefs, resolvers });

// The context is a function or object that can add some extra data
// That will be available via the `context` argument the resolver functions
const context = ({ req }) => {
return {
serverName: "Voyager Server"
};
};

// Initialize the apollo voyager server with our schema and context
const server = ApolloVoyagerServer({
// Initialize the voyager server with our schema and context
const server = VoyagerServer({
typeDefs,
resolvers,
playground: {
tabs: [
{
endpoint: "/graphql",
endpoint: '/graphql',
variables: {},
query: queries
}
]
},
schema,
context
});
}
})

const app = express();
server.applyMiddleware({ app });
const app = express()
server.applyMiddleware({ app })

module.exports = { app, server };
module.exports = { app, server }

0 comments on commit fd22e3c

Please sign in to comment.