What is a suitable backend for relayjs? - relayjs

I am having trouble understanding how to hook up a backend that will support relayjs. Does GraphQL/Relay automatically help store queries? I.e. if I implement a REST backend that returns a json blob with everything, will Relay take care of the data query optimizations? I'm not entirely sure of the abstraction between Relay and backend/database.

Take a look at Getting Started in the Relay documentation. Relay requires that you have a GraphQL server that understands GraphQL queries and can respond with valid response payloads.
GraphQL provides an abstraction with which Relay uses to interface with your backend. GraphQL is not a database, but rather a layer that sits on top of your server application code. For example, you could implement a GraphQL server that sits in front of your REST server as demonstrated by the graphql/swapi-graphql repository.
Nick Schrock's presentation of GraphQL at #Scale 2015 also provides a good overview.

Related

UI5 oData Service for two (or more) different backends

At the moment i still only have about 2 months of experience in UI5. i developed a little sample-app, used sap gateway builder to pass my requests to sap backend.
Now my employer asked me to research the possibility to access two different backends (one sap, one nonsap) via odata from the same app. After a little reading and thinking i came to the conclusion that it would be best to access both backends from a single gateway.
Since ive already worked with sap gateway, i wonder if there is a way to access nonsap backends with sap gateway? Are the better options?
Or is my current approach complete wrong and i should think about a whole other way?
It depends on your approach and the non-sap-system:
Is the non-sap-system accesible via Webservices? Then use second data model (e.g. JSON/ODATA) within SAPUI5 by loading data via webservices after initial loadup of your application.
Is the non-sap-system connected to SAP? E.g. via RFC or another technology, then you can read data from the other system during calling your initial Gateway service and simply call your RFC function module in your method.
From my opinion you will not achieve an 'easy' way to read both via one single SAP NetWeaver Gateway.
Not sure why you would want to access a non-SAP oData service via SAP Gateway. On the other hand you may want a router of some sort so that all services are exposed on the same network location and then incoming requests are routed to the appropriate backend for action.
You may also want to "mash-up" the SAP and non-SAP services into some sort of new service. In that case maybe look to some of the API management tools like Apigee to help you achieve that.

IMAP Server Facade - how to make one?

I have implemented a custom email server and web client. The server is just a REST API (similar to google's gmail API) that uses a 3rd party (sendgrid) for sending and receiving. The emails are stored in a database. The web client just talks to the REST client for sending and receiving.
The problem with this approach is it doesn't implement IMAP anywhere, which makes it impossible for standard clients (outlook, iphone, etc.) to connect to and use our email API. This limits customers to using only our client for email.
What I need is some sort of IMAP Server "facade" that will manage the connections to clients and make calls to my REST API for actually handling the requests (get email, send email, etc.).
How can an IMAP facade be implemented? Is there maybe a way to take an existing MailServer and gut it and point all it's "events" to making calls to my API?
tl:dr; write your gateway in Perl; use Net::IMAP::Server; override Net::IMAP::Server::Mailbox; and use one of the many Perl REST clients to talk to your server.
Your best bet for doing this quickly, while maintaining a reasonable amount of code security, is with Perl. You'll need two Perl modules. The first is Net::IMAP::Server, and here is the Github repository for that module. This is a standards-compliant RFC 3501 server that was purposely designed to have a configurable mail store. You will override the default Net::IMAP::Server::Mailbox implementation with your own code that talks to your custom email backend.
For your second module, choose your favorite Perl module(s) to use to speak to your REST server. Your choice depends on how much fine grained control you want to have over the construction and delivery of the REST messages.
Fortunately, here you have tons of choices. One possibility is Eixo::REST, which has a Github repository here. Eixo::REST seems to deal well with asynchronous vs. synchronous REST API calls, but it doesn't provide a lot of control over X509 key management. Depending on how googley your API is, there's also the REST::Google module. Interestingly, this family also has a REST::Google::Apps::EmailSettings module, specifically for setting Gmail-specific funkiness like labels and languages. Lastly, the REST::Consumer module seems to encapsulate a lot of https-specific things like timeout and authentication as parameters to Perl object instantiation.
If you use these existing frameworks, then about 90% of the necessary code should already be done for you.
Don't do this by hacking Dovecot or any other mail server written in C or C++. If you hack together a mail server quickly using a compiled language, your server will sooner or later experience all the joy of buffer overflows and stack smashing and everything else that the Internet does to fuck over mail servers. Get it working safely first, then optimize later.
(This is basically my comment again, but elaborated quite a bit more.)
Some IMAP servers, most notably Dovecot, are structured such that the file access is in a separate module with a defined interface. Dovecot isn't the only one, but it's by far the most popular and its backend interface is known to be appropriate, so I'd take that absent specific concerns.
There already exist non-file modules such as imapc, which proves that it can be done. When a client opens a mailbox backed by imapc, Dovecot parses IMAP commands, calls message access functions in imapc, imapc issues new IMAP commands, parses the server responses, returns C structs to Dovecot, Dovecot fashions new IMAP responses and returns them to the client.
I suggest that you take the dovecot source, look at src/lib-storage/inbox/index/imapc and the other backends in that directory, and implement one that speaks your REST API as a client.
Since you're familiar with .NET, I would suggest hacking either of the following implementations of IMAPv4 servers to your liking:
Lumisoft Mail Server - a very old project indeed (let's call it "mature", huh?). Don't be too turned off by the decade-old website and the lack of a github link - the source is provided under "other downloads".
McNNTP - also an older project and with a major focus on NNTP (as the name says) but very close to what you're trying to achieve in terms of the IMAP component. Take a look, you'll probably find this a good starting point.

Integrating RelayJS and Azure table storage

The documentation on RelayJS says the RelayJS can use node.js as a GraphQL server, but not ASP.NET web service.
How can I use RelayJS with ASP.NET web api end point?
How can I use RelayJS with ASP.NET web api end point?
TL;DR;
By placing a GraphQL server in-between Relay client-side and ASP.NET web api end point.
The Getting Started page of Relay documentation clearly mentions that 2 additional things are needed to use Relay:
A GraphQL Schema: This is your data model. You need to map your ASP.NET web API to a GraphQL schema.
A GraphQL Server: Your client-side speaks to this server. In your case, this GraphQL server will talk to your ASP.NET web API.
A good example of this is GraphQL schema and server wrapping Star Wars API.
Some conecptual clarifications about your question
Relay is a specification. It's actually called GraphQL Relay Specification. It's not restricted to JavaScript. Check Awesome Relay to find the list of languages for which Relay libraries are already available.
It helps to think of Relay and GraphQL as 2 sides:
server-side consisting of GraphQL server, which speaks the schema. It can receive queries and mutation requests. How you prepare and provide the requested data depend on back-end logic. For example, you may have your own database, which you use directly to fetch / prepare the exposed data. Or you may use an external API to fetch / prepare data.
There are libraries in languages other than JavaScript to help you write GraphQL schema and server. Check Awesome GraphQL.
client-side using Relay library, which talks to a GraphQL server and fetches data as needed.

EHR intercommunication / client

So, I'm researching methods for building a client interface for existing EMRs. I've read tons of info on HL7, as well as the various coding schemes, but I'm still really clueless.
For anyone whose worked with an EMR before: is it possible to build a web interface that can use HTTP-POST and HTTP-GET requests to pull/push data to the server database? Or would you have a separate database for the client, say a web application, then use some interface engine like Mirth to communicate between the EMR database and the web application?
A web service API is definitely a way to go. One benefit to this is that you can get https almost out-of-the box for encryption of data in transit.
The way we have configured our EMR is that we have a tcp server accepting incoming hl7 messages from certain IPs which connects directly to our EMR database. This can be beneficial by separating emr and interface processes (You don't have to restart your whole EMR if the interface goes down, for instance).
Another good feature would be to have a token system for pseudo-authentication. This only works if you are going over a secure connection though.
If you aren't into writing your own tcp server (not that hard), an api-based server is probably just as good.
EDIT: What language(s) do you think you'll be using?
Other things that you might run into:
Some applications prefer file drops to direct calls (either url or tcp)
Some vendors will have their own software that sits on a server of yours
Don't forget the ACK.
I don't see why you couldn't do this. You would need to build the web service to handle requests with a specific Uri. When this Uri is called the web service uses the data sent with the request to make changes in the database.
Once you had the web service built, you could build some sort of front-end that displays your information to the user. And makes HTTP-GET and HTTP-POST calls.
There is a lot of flexibililty in what you are trying to do... so go with a plan for sure.
In general though you should be able to accomplish what you need to do by building your own web service and front-end application that is able to manipulate an EMR database.
It really depends on your architecture and requirements.
Architecture 1
If you want your client to be web based, but your client is a separated app from your backend, then the web sends the info using HTTP to your client app server side, and then, that will send info to your EHR backend (another app). That second communication might be written using a standard, that will help you on integrating more systems with your backend in the future. So that interface can be HL7 based, if HL7 v2.x is used, take a look at the MLLP protocol: http://www.hl7.org/implement/standards/product_brief.cfm?product_id=55
This is the most performant way of communicating HL7 data. If you don't want to deal with TCP, there is a proposal for HL7 v2.x over HTTP. HAPI implemented that: http://hl7api.sourceforge.net/hapi-hl7overhttp/
If you don't want to use HL7 v2.x but HL7 v3 (a different standard, not really a version of 2.x) or CDA, you can use HTTP or SOAP.
Architecture 2
But, if you want your client just to be a UI on the user side (browser), HTTP POST will suffice to send info from the browser to the server. That means your EHR is a centralized EHR with a web iu.
In the 1st architectural case, first case you'll probably have multiple client apps (full EMRs apps) and a backend EHR server (centralized backend). On my developments I follow this second architecture.
Also there Mirth might help to manage all the communications between client apps and backend apps. In the 2nd case, using Mirth is nonsense, is just a web application and the client communicates directly with the web server. Of course, you can use Mirth as a web server, but that's not it's role, it is an ESB no a web server.
Hope that helps!

Using a web service in an iOS app

How might I go about using a web service in an iPhone app? For example, if I wanted to use a web service that you can use to convert a value into a different unit, how would I go about doing that? For example: http://www.webqc.org/balance.php
It depends what sort of 'web service' it is. If it is a stateless REST style API, passing data in the URL and/or data encoded Json or XML it couldn't be easier, just use NSURLConnection.
Using examples I found on the web I made an application (server and iOS client) - using the NSURLConnection & NSMutableURLRequest, and encoded/decoded data using YAJL. This was pretty easy to get going.
If you don't want to do this using the core libraries directly- there are some frameworks you can use, e.g. RestKit. I've not used it, but it looks good and comes recommended.
If it is a SOAP style web service, this is a lot more complicated as SOAP services often expose a stateful API.
I should say that the example that you show here is not a web-service, whilst it does come with a way of calling it just using a URL - it returns an html page which makes it hard for you to use the results. I presume that you are more interested in a service that returns results encoded as XML or Json or the like.

Resources