Skip to content

Commit

Permalink
Merge pull request #455 from 99designs/fix-deprecated-fields
Browse files Browse the repository at this point in the history
Fix deprecated fields
  • Loading branch information
vektah committed Nov 28, 2018
2 parents 4bfc82d + b365333 commit 3a7f37c
Show file tree
Hide file tree
Showing 18 changed files with 294 additions and 126 deletions.
10 changes: 10 additions & 0 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Gopkg.toml
Expand Up @@ -14,7 +14,7 @@ required = ["github.com/vektah/dataloaden"]

[[constraint]]
name = "github.com/vektah/gqlparser"
revision = "^1.0.0"
version = "^1.0.0"

[prune]
go-tests = true
Expand All @@ -23,3 +23,7 @@ required = ["github.com/vektah/dataloaden"]
[[constraint]]
name = "gopkg.in/yaml.v2"
version = "2.2.1"

[[constraint]]
name = "github.com/rs/cors"
version = "1.6.0"
24 changes: 16 additions & 8 deletions codegen/testserver/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions codegen/testserver/generated_test.go
Expand Up @@ -222,6 +222,32 @@ func TestIntrospection(t *testing.T) {
var resp interface{}
err := c.Post(introspection.Query, &resp)
require.NoError(t, err)

t.Run("does not return empty deprecation strings", func(t *testing.T) {
q := `{
__type(name:"InnerObject") {
fields {
name
deprecationReason
}
}
}`

c := client.New(srv.URL)
var resp struct {
Type struct {
Fields []struct {
Name string
DeprecationReason *string
}
} `json:"__type"`
}
err := c.Post(q, &resp)
require.NoError(t, err)

require.Equal(t, "id", resp.Type.Fields[0].Name)
require.Nil(t, resp.Type.Fields[0].DeprecationReason)
})
})

t.Run("disabled by middleware", func(t *testing.T) {
Expand All @@ -244,6 +270,7 @@ func TestIntrospection(t *testing.T) {
err := c.Post(introspection.Query, &resp)
require.EqualError(t, err, "[{\"message\":\"introspection disabled\",\"path\":[\"__schema\"]}]")
})

}

var _ graphql.Tracer = (*testTracer)(nil)
Expand Down
24 changes: 16 additions & 8 deletions example/chat/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 19 additions & 9 deletions example/chat/package.json
Expand Up @@ -3,20 +3,30 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"apollo-cache-inmemory": "^1.1.9",
"apollo-client": "^2.2.5",
"graphql-tag": "^2.9.1",
"graphql": "^0.13.2",
"react": "^16.2.0",
"react-apollo": "^2.1.0-beta.2",
"react-dom": "^16.2.0",
"react-scripts": "1.1.1",
"apollo-cache-inmemory": "^1.3.11",
"apollo-client": "^2.4.7",
"apollo-link": "^1.2.4",
"apollo-link-http": "^1.5.7",
"apollo-link-ws": "^1.0.10",
"apollo-utilities": "^1.0.26",
"graphql": "^14.0.2",
"graphql-tag": "^2.10.0",
"react": "^16.6.3",
"react-apollo": "^2.3.1",
"react-dom": "^16.6.3",
"react-scripts": "^2.1.1",
"subscriptions-transport-ws": "^0.9.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
10 changes: 8 additions & 2 deletions example/chat/server/server.go
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/99designs/gqlgen/handler"
"github.com/gorilla/websocket"
"github.com/opentracing/opentracing-go"
"github.com/rs/cors"
"sourcegraph.com/sourcegraph/appdash"
appdashtracer "sourcegraph.com/sourcegraph/appdash/opentracing"
"sourcegraph.com/sourcegraph/appdash/traceapp"
Expand All @@ -18,13 +19,18 @@ import (
func main() {
startAppdashServer()

c := cors.New(cors.Options{
AllowedOrigins: []string{"http://localhost:3000"},
AllowCredentials: true,
})

http.Handle("/", handler.Playground("Todo", "/query"))
http.Handle("/query", handler.GraphQL(chat.NewExecutableSchema(chat.New()),
http.Handle("/query", c.Handler(handler.GraphQL(chat.NewExecutableSchema(chat.New()),
handler.WebsocketUpgrader(websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
})),
}))),
)
log.Fatal(http.ListenAndServe(":8085", nil))
}
Expand Down
29 changes: 24 additions & 5 deletions example/chat/src/index.js
Expand Up @@ -3,16 +3,35 @@ import ReactDOM from 'react-dom';
import { ApolloProvider } from 'react-apollo';
import ApolloClient from 'apollo-client';
import App from './App';
import { SubscriptionClient } from 'subscriptions-transport-ws';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { split } from 'apollo-link';
import { HttpLink } from 'apollo-link-http';
import { WebSocketLink } from 'apollo-link-ws';
import { getMainDefinition } from 'apollo-utilities';


const client = new SubscriptionClient('ws://localhost:8085/query', {
reconnect: true,
const wsLink = new WebSocketLink({
uri: `ws://localhost:8085/query`,
options: {
reconnect: true
}
});

const httpLink = new HttpLink({ uri: 'http://localhost:8085/query' });


// depending on what kind of operation is being sent
const link = split(
// split based on operation type
({ query }) => {
const { kind, operation } = getMainDefinition(query);
return kind === 'OperationDefinition' && operation === 'subscription';
},
wsLink,
httpLink,
);

const apolloClient = new ApolloClient({
link: client,
link: link,
cache: new InMemoryCache(),
});

Expand Down
24 changes: 16 additions & 8 deletions example/config/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3a7f37c

Please sign in to comment.