Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions api/Articles/host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[2.*, 3.0.0)"
}
}
15 changes: 7 additions & 8 deletions api/Articles/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
var jsonData = require('../generate');

module.exports = async function (context, req) {
const byId = (req.query.id);
context.res = {
// status: 200, /* Defaults to 200 */
body: byId ? [jsonData().articles[byId]] : jsonData().articles
};
var jsonData = require('../generate');

module.exports = async function (context, req) {
const byId = (req.query.id);
context.res = {
body: byId ? [jsonData().articles[byId]] : jsonData().articles
};
}
20 changes: 20 additions & 0 deletions api/graphql/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post",
"options"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
7 changes: 7 additions & 0 deletions api/graphql/host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
}
27 changes: 27 additions & 0 deletions api/graphql/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { gql, ApolloServer } = require("apollo-server-azure-functions");

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

// A map of functions which return data for the schema.
const resolvers = {
Query: {
hello: () => "world"
}
};

const server = new ApolloServer({ typeDefs, resolvers, debug: true, playground: true });

module.exports = server.createHandler({
cors: {
origin: [
'https://studio.apollographql.com',
],
methods: ['GET', 'POST', 'OPTIONS'],
credentials: true,
},
});
3 changes: 3 additions & 0 deletions api/graphql/sample.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "Azure"
}
Loading