From e73220e4d60e7b33ec2572ebc90a5f101a735796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Mon, 22 Apr 2019 11:45:15 +0100 Subject: [PATCH 001/104] Create call-graphql.go --- examples/call-graphql.go | 93 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 examples/call-graphql.go diff --git a/examples/call-graphql.go b/examples/call-graphql.go new file mode 100644 index 00000000..ab72c141 --- /dev/null +++ b/examples/call-graphql.go @@ -0,0 +1,93 @@ +package main + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "io/ioutil" + "net/http" + "os" +) + +func jsonPrettyPrint(in []byte) string { + var out bytes.Buffer + err := json.Indent(&out, in, "", " ") + if err != nil { + return string(in) + } + return out.String() +} + +var HASURA_GRAPHQL_ADDRESS = os.Getenv("HASURA_GRAPHQL_ADDRESS") +var HASURA_GRAPHQL_ADMIN_SECRET = os.Getenv("HASURA_GRAPHQL_ADMIN_SECRET") + +type GraphqlQuery struct { + Data interface{} +} + +var client = &http.Client{Transport: http.DefaultTransport} + +func hasura(query string, variables interface{}, data interface{}) (err error) { + variablesBytes, err := json.Marshal(variables) + if err != nil { + return + } + + v := string(variablesBytes) + requestBody := []byte(`{"query":"` + query + `","variables":` + v + `}`) + requestBytes := bytes.NewBuffer(requestBody) + req, err := http.NewRequest("POST", HASURA_GRAPHQL_ADDRESS, requestBytes) + if err != nil { + return + } + + req.Header.Add("X-Hasura-Admin-Secret", HASURA_GRAPHQL_ADMIN_SECRET) + + resp, err := client.Do(req) + if err != nil { + return + } + + b, err := ioutil.ReadAll(resp.Body) + if err != nil { + return + } + + // loggin the answer for debugging purposes + fmt.Println(jsonPrettyPrint(b)) + + if resp.StatusCode < 200 || resp.StatusCode > 299 { + return errors.New(http.StatusText(resp.StatusCode)) + } + + gqlQuery := GraphqlQuery{Data: data} + err = json.Unmarshal(b, &gqlQuery) + if err != nil { + return + } + return +} + +type User struct { + GithubLogin string +} + +const userQuery = ` +query { + user { + githubLogin + } +}` + +func getUsers() (users []User, err error) { + var data map[string][]User + err = hasura(userQuery, nil, &data) + return data["user"], err +} + +func main() { + fmt.Println(getUsers()) +} + +// HASURA_GRAPHQL_ADMIN_SECRET=VERYVERYSECRET HASURA_GRAPHQL_ADDRESS=http://localhost/graphql-engine/v1alpha1/graphql go run call-graphql.go From 1142d3429126759a8eacd4e7489b6374344784bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment?= Date: Mon, 22 Apr 2019 11:54:54 +0100 Subject: [PATCH 002/104] Remove supefluous check --- examples/call-graphql.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/examples/call-graphql.go b/examples/call-graphql.go index ab72c141..9ef6af54 100644 --- a/examples/call-graphql.go +++ b/examples/call-graphql.go @@ -61,12 +61,7 @@ func hasura(query string, variables interface{}, data interface{}) (err error) { return errors.New(http.StatusText(resp.StatusCode)) } - gqlQuery := GraphqlQuery{Data: data} - err = json.Unmarshal(b, &gqlQuery) - if err != nil { - return - } - return + return json.Unmarshal(b, &GraphqlQuery{Data: data}) } type User struct { From fdba51f5ebcd025a04bebde77c1ef0f47603f8e2 Mon Sep 17 00:00:00 2001 From: Louise Foussat Date: Mon, 22 Apr 2019 14:51:05 +0100 Subject: [PATCH 003/104] create first doc for step creation in signup/administrative part --- doc/create-steps.md | 152 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 doc/create-steps.md diff --git a/doc/create-steps.md b/doc/create-steps.md new file mode 100644 index 00000000..0f583973 --- /dev/null +++ b/doc/create-steps.md @@ -0,0 +1,152 @@ +# How to create onboarding steps + +## Usage +This documentation explains how to create steps in your onboarding. 2 kind of steps can be generated in a modular way : +* forms +* documents to sign + +These steps are used for the "sign up" phase, and for the administrative part of the onboarding. + +## Description & examples +The sign up phase and the administration part of the onboarding are related to major objects in the admin. all the steps for each of these two sections are children of these two big objects, that you can create, update, or delete, and order as you wish. +The objects contained in the sign up phase are object of type "sign up". +The objects contained in the administration part of the onboarding phase are object of type "onboarding". + +### Relate a step to a major object +Every step is related to the major object you want to costum as a child. To create a child, you must : +1. Create a new object for your step in the admin (in Admin > "Add new object") + * The title of your object will be the title displayed for the step you're creating. Use a intellegible title for your user. + * This object must have the same type as your major object ("signup" for the sign up phase, "onboarding" for the administration part of the onboarding) +2. Add this new object as a child of your major object + 1. Edit the major object + 2. Go to "Children" > "Add a child" + 3. Set up the new child: + * Enter its name in the input "Add a child name" + * Select you child in the select input + * Click on "ADD" + +### Settings for a form step +In the child object you've created, 2 attributes must be filled: +1. subtype +2. form + +To set up the child object you've created with these elements : +1. Edit you child object +2. Go to "Object attributes" +3. Add the attributes : + 1. Add a new key "subtype" of type `` with the value 'onb-adm-form' + 2. Add a new key "form" of type `` + * The form you're creating can have several sections. Each section is displayed with a title, and its inputs. + NB : The submission of the form will check the required inputs of all the sections you've created. + * To create a section, add a new key to your form object, of type ``, that contains : + 1. A key "title" of type ``. The value of this property will be the title displayed in the top of your form section. If you have only one section in your form step, and you don't need a section title, you don't have to set up this property. + 2. An "inputs" key of type ``, which will contain all the inputs of the section. For each input you want to add, you must set up the input as this : + * Add a new `` element in the "inputs" object. The key of this object will be used as the "name" attribute of your input. The values will be considered as the props of your input. + +Set up of an input props : +* You must declare a "type" key of type ``, wich define the type of your input : ``, ``, ``, `