BOD-14 Backend server work + sending of messages WIP for front end
This commit is contained in:
9
server/graphql-client/graphql-client.js
Normal file
9
server/graphql-client/graphql-client.js
Normal file
@@ -0,0 +1,9 @@
|
||||
const GraphQLClient = require("graphql-request").GraphQLClient;
|
||||
require("dotenv").config();
|
||||
|
||||
//TODO May need to use a different client that includes caching of resources.
|
||||
exports.client = new GraphQLClient(process.env.GRAPHQL_ENDPOINT, {
|
||||
headers: {
|
||||
"x-hasura-admin-secret": process.env.HASURA_ADMIN_SECRET
|
||||
}
|
||||
});
|
||||
23
server/graphql-client/queries.js
Normal file
23
server/graphql-client/queries.js
Normal file
@@ -0,0 +1,23 @@
|
||||
exports.FIND_BODYSHOP_BY_MESSAGING_SERVICE_SID = `
|
||||
query FIND_BODYSHOP_BY_MESSAGING_SERVICE_SID(
|
||||
$mssid: String!
|
||||
$phone: String!
|
||||
) {
|
||||
bodyshops(where: { messagingservicesid: { _eq: $mssid } }) {
|
||||
id
|
||||
conversations(where: { phone_num: { _eq: $phone } }) {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
exports.INSERT_MESSAGE = `
|
||||
mutation INSERT_MESSAGE($msg: [messages_insert_input!]!) {
|
||||
insert_messages(objects: $msg) {
|
||||
returning {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
Reference in New Issue
Block a user