Categorygithub.com/desteves/realm
module
0.0.0-20201214175220-0edac8c0d24d
Repository: https://github.com/desteves/realm.git
Documentation: pkg.go.dev

# README

mongodb realm go package

Contains a mongoDB Realm Authentication package and a GraphQL Client package which authenticates and runs queries and mutations against Realm's GraphQL Server.

See examples/

Usage

Note: This requires to have Atlas and Realm set up. See below for details.

go get https://github.com/desteves/realm
import  "github.com/desteves/realm/pkg/graphql"

Atlas Setup

  • Create new project under an organization. Register here
  • Create new free cluster, call it graphqlDatabase.
  • Load 'Sample Data Set'. Steps here

Realm Setup

Via the UI

  • Create new realm app, call it graphqlServer. Steps here
    • Write down app id graphqlserver-?????
  • Enable anonymous authentication. Steps here
  • Enable GraphQL and configure. Steps here
    • Generate schemas
    • Select any of the sample-* databases/collections and click 'Generate Schema'.
      • Enable read/write access

(Optional) Set up webhook

This is an additional check to verify our client has network connectivty.

Follow the steps listed here

  • Name the service as ping
  • Name the webhook as test
  • Only allow the GET HTTP Method
  • Paste the following in the function
  // This function is the webhook's request handler.
  exports = function(payload, response) {
    response.setStatusCode(200);
    response.setBody(
    "{'message': 'pong'}"
  );
  };

See examples/anonymousauth/main.go for usage.

(Optional) Set up dummy GraphQL record

This is to verify our client can reach the graphql server and obtain a valid response.

Insert the following to your atlas cluster. This example is from the mongo shell:


var appid = "graphqlserver-?????" // <------- UPDATE THIS!!!
use graphql
db.health.insertOne({
 "appid": appid,
 "description": "Checks GraphQL Server is reachable and operational",
 "status": "pass",
 "endpoint": "https://realm.mongodb.com/api/client/v2.0/app/"+appid+"/graphql"
})

See examples/graphqlhealthcheck/main.go for usage.

Via the CLI

npm install -g mongodb-realm-cli
realm-cli login --api-key="AAAAAAA" --private-api-key="AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA"

// todo

TODO (work in progress)

  • BUG: Don't show errors array when no error.
  • Add Atlas API && Realm-CLI commands for the Atlas+Realm Set up
  • Testing

References

# Packages

No description provided by the author
No description provided by the author