Skip to content

Commit

Permalink
Merge branch 'master' into issue-2542-clean-schema-update-table
Browse files Browse the repository at this point in the history
Resolve Conflicts:
	server/src-exec/Migrate.hs
  • Loading branch information
rakeshkky committed Jul 31, 2019
2 parents ce85db0 + a8a18e0 commit 4735a57
Show file tree
Hide file tree
Showing 120 changed files with 14,118 additions and 1,225 deletions.
13 changes: 12 additions & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/briandowns/spinner"
"github.com/gofrs/uuid"
"github.com/hasura/graphql-engine/cli/version"
colorable "github.com/mattn/go-colorable"
"github.com/mattn/go-colorable"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
Expand Down Expand Up @@ -171,6 +171,9 @@ type ExecutionContext struct {
// LogLevel indicates the logrus default logging level
LogLevel string

// NoColor indicates if the outputs shouldn't be colorized
NoColor bool

// Telemetry collects the telemetry data throughout the execution
Telemetry *telemetry.Data

Expand Down Expand Up @@ -343,6 +346,7 @@ func (ec *ExecutionContext) Spin(message string) {
func (ec *ExecutionContext) setupLogger() {
if ec.Logger == nil {
logger := logrus.New()

logger.Formatter = &logrus.TextFormatter{
ForceColors: true,
DisableTimestamp: true,
Expand All @@ -351,6 +355,13 @@ func (ec *ExecutionContext) setupLogger() {
ec.Logger = logger
}

if ec.NoColor {
ec.Logger.Formatter = &logrus.TextFormatter{
DisableColors: true,
DisableTimestamp: true,
}
}

if ec.LogLevel != "" {
level, err := logrus.ParseLevel(ec.LogLevel)
if err != nil {
Expand Down
12 changes: 7 additions & 5 deletions cli/commands/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ var ravenVersions = []mt.Version{
}

var testMetadataPrev = map[string][]byte{
"metadata": []byte(`functions: []
"metadata": []byte(`allowlist: []
functions: []
query_collections: []
query_templates: []
remote_schemas: []
tables:
Expand All @@ -44,7 +46,9 @@ tables:
table: test
update_permissions: []
`),
"empty-metadata": []byte(`functions: []
"empty-metadata": []byte(`allowlist: []
functions: []
query_collections: []
query_templates: []
remote_schemas: []
tables: []
Expand All @@ -55,7 +59,6 @@ var testMetadataCurrent = map[string][]byte{
"metadata": []byte(`allowlist: []
functions: []
query_collections: []
query_templates: []
remote_schemas: []
tables:
- array_relationships: []
Expand All @@ -70,7 +73,6 @@ tables:
"empty-metadata": []byte(`allowlist: []
functions: []
query_collections: []
query_templates: []
remote_schemas: []
tables: []
`),
Expand Down Expand Up @@ -262,7 +264,7 @@ func mustWriteFile(t testing.TB, dir, file string, body string) {

func compareMetadata(t testing.TB, metadataFile string, actualType string, serverVersion *semver.Version) {
var actualData []byte
c, err := semver.NewConstraint("<= 1.0.0-alpha45")
c, err := semver.NewConstraint("<= v1.0.0-beta.3")
if err != nil {
t.Fatal(err)
}
Expand Down
1 change: 1 addition & 0 deletions cli/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func init() {
f.StringVar(&ec.LogLevel, "log-level", "INFO", "log level (DEBUG, INFO, WARN, ERROR, FATAL)")
f.StringVar(&ec.ExecutionDirectory, "project", "", "directory where commands are executed (default: current dir)")
f.BoolVar(&ec.SkipUpdateCheck, "skip-update-check", false, "Skip automatic update check on command execution")
f.BoolVar(&ec.NoColor, "no-color", false, "do not colorize output (default: false)")
}

// Execute executes the command and returns the error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ $ cd graphql-engine/community/boilerplates/remote-schemas/google-cloud-functions
Start a local development server (you may need to install dependencies from npm):

```bash
$ npm i --no-save apollo-server express
$ npm i --no-save apollo-server
$ node localDev.js

Output:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
const { ApolloServer } = require('apollo-server');
const express = require('express');
const app = express();

const { typeDefs, resolvers } = require('./index');

const helloSchema = new ApolloServer({ typeDefs, resolvers });
const server = new ApolloServer({ typeDefs, resolvers });

helloSchema.listen().then(({ url }) => {
server.listen().then(({ url }) => {
console.log(`schema ready at ${url}`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ will be a critical portion of our todo app. 😉
> Head to GraphiQL and on the right, click on the "docs" tab.
> Type "todo" there and you'll see a list of GraphQL queries and types
> that use todo. Read through their descriptions and you'll soon
> find that `insert_todo` is what you need.
> find that `insert_todos` is what you need.
The mutation to create todos is titled `insert_todos`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import YoutubeEmbed from "../../src/YoutubeEmbed.js";

<YoutubeEmbed link="https://www.youtube.com/embed/fU2HIMn_QwE" />

Open `src/Todo/TodoPrivateList.js` and set the client that we receive as prop.
Open `src/components/Todo/TodoPrivateList.js` and set the client that we receive as prop.

<GithubLink link="https://github.com/hasura/graphql-engine/blob/master/community/learn/graphql-tutorials/tutorials/react-apollo/app-final/src/components/Todo/TodoPrivateList.js" text="src/components/Todo/TodoPrivateList.js" />

Expand Down Expand Up @@ -58,4 +58,4 @@ clearCompleted() {
}
```
That's a wrap of the basic todo app.
That's a wrap of the basic todo app.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ So let's define the graphql subscription to be used.

Open `src/components/OnlineUsers/OnlineUsersWrapper.js` and add the following code, below the other imports

<GithubLink link="https://github.com/hasura/graphql-engine/blob/master/community/learn/graphql-tutorials/tutorials/react-apollo/app-final/src/OnlineUsers/OnlineUsersWrapper.js" text="src/OnlineUsers/OnlineUsersWrapper.js" />
<GithubLink link="https://github.com/hasura/graphql-engine/blob/master/community/learn/graphql-tutorials/tutorials/react-apollo/app-final/src/components/OnlineUsers/OnlineUsersWrapper.js" text="src/components/OnlineUsers/OnlineUsersWrapper.js" />

```javascript
- import React, { Component } from "react";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Let us integrate the remove todos feature in our React Native app. Firstly impor
+`;
```

Now, in the render method of the `TodoItem` component, update the `deletetButton` function to wrap the button JSX with a `Mutation` component.
Now, in the render method of the `TodoItem` component, update the `deleteButton` function to wrap the button JSX with a `Mutation` component.

```js

Expand Down
47 changes: 47 additions & 0 deletions community/sample-apps/gatsby-contentful-auth0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# gatsby-contentful-auth0
This is the sample music playlist application demonstrating the Gatsby + Contentful Remote Join with Hasura GraphQL.

## Getting started

If you've cloned this repository, navigate into the directory and install the npm modules using this command:

```bash
npm install
```

> Note: if you clone this project through the Gatsby CLI, it will install the modules for you.
## Auth0
This application uses Auth0 to manage identity. Refer to the [Auth0 integration guide](https://docs.hasura.io/1.0/graphql/manual/guides/integrations/auth0-jwt.html) for the configuration.

### Modify auth config

Rename `.env.EXAMPLE` to `.env.development` (or `.env.production`) and replace `<value>` for `AUTH0_DOMAIN` and `AUTH0_CLIENTID` with your Auth0 domain prefix and your client ID. These can be found on your [client dashboard](https://manage.auth0.com/#/clients).

Replace the `<value>` for `AUTH0_CALLBACK` with the URL for your callback route. The default for development is `http://localhost:8000/callback`.

## Contentful
Contentful remote schema is added as part of the migration. Configure the environment variables in Hasura GraphQL Engine server for the types to get merged.

- `CONTENTFUL_API_KEY`
- `CONTENTFUL_API_ENDPOINT` which is of the format https://graphql.contentful.com/content/v1/spaces/<space-id>

## Migrations

Execute the following command inside `hasura` to apply the migrations

```bash
hasura migrate apply
```

This will create all the necessary tables, relationships and remote joins.

## Run the app
You can start the development server with the following command:

```bash
gatsby develop
```

The app runs at `localhost:8000` by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ./.env
# Get these values at https://manage.auth0.com and create a new file called .env.development
AUTH0_DOMAIN=<value>
AUTH0_CLIENTID=<value>
AUTH0_CALLBACK=<value>
71 changes: 71 additions & 0 deletions community/sample-apps/gatsby-contentful-auth0/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# dotenv environment variables file
.env
.env.*
!.env.EXAMPLE

# gatsby files
.cache/
public

# Mac files
.DS_Store

# Yarn
yarn-error.log
.pnp/
.pnp.js
# Yarn Integrity file
.yarn-integrity
7 changes: 7 additions & 0 deletions community/sample-apps/gatsby-contentful-auth0/app/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"endOfLine": "lf",
"semi": false,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5"
}
28 changes: 28 additions & 0 deletions community/sample-apps/gatsby-contentful-auth0/app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# gatsby-contentful-auth0
This is the sample music playlist application demonstrating the Gatsby + Contentful Remote Join with Hasura GraphQL.

## Getting started

If you've cloned this repository, navigate into the directory and install the npm modules using this command:

```bash
npm install
```

> Note: if you clone this project through the Gatsby CLI, it will install the modules for you.
## Modify auth config

Rename `.env.EXAMPLE` to `.env.development` (or `.env.production`) and replace `<value>` for `AUTH0_DOMAIN` and `AUTH0_CLIENTID` with your Auth0 domain prefix and your client ID. These can be found on your [client dashboard](https://manage.auth0.com/#/clients).

Replace the `<value>` for `AUTH0_CALLBACK` with the URL for your callback route. The default for development is `http://localhost:8000/callback`.

## Run the app
You can start the development server with the following command:

```bash
gatsby develop
```

The app runs at `localhost:8000` by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from "react"
import { silentAuth } from "./src/utils/auth"

class SessionCheck extends React.Component {
constructor(props) {
super(props)
this.state = {
loading: true,
}
}

handleCheckSession = () => {
this.setState({ loading: false })
}

componentDidMount() {
silentAuth(this.handleCheckSession)
}

render() {
return (
this.state.loading === false && (
<React.Fragment>{this.props.children}</React.Fragment>
)
)
}
}

export const wrapRootElement = ({ element }) => {
return <SessionCheck>{element}</SessionCheck>
}
22 changes: 22 additions & 0 deletions community/sample-apps/gatsby-contentful-auth0/app/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const fetch = require(`node-fetch`)
const { createHttpLink } = require(`apollo-link-http`)

module.exports = {
plugins: [
{
resolve: 'gatsby-source-graphql',
options: {
typeName: 'HASURA',
fieldName: 'hasura',
createLink: (pluginOptions) => {
return createHttpLink({
uri: 'http://localhost:8080/v1/graphql',
headers: {
},
fetch,
})
},
},
},
]
};
Loading

0 comments on commit 4735a57

Please sign in to comment.