This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
apiVersion: v1 | |
kind: Template | |
labels: | |
template: ionic-showcase-server | |
metadata: | |
name: datasync-showcase-server | |
annotations: | |
openshift.io/display-name: AMQ Resources Template |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { ApolloServer, gql } = require('apollo-server-express') | |
const Keycloak = require('keycloak-connect') | |
const { KeycloakContext, KeycloakTypeDefs, KeycloakSchemaDirectives } = require('keycloak-connect-graphql') | |
const { typeDefs, resolvers } = require('./schema') | |
const app = express() | |
const keycloak = new Keycloak() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const typeDefs = gql` | |
type Article { | |
id: ID! | |
title: String! | |
content: String! | |
} | |
type Query { | |
listArticles: [Article]! @auth | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { auth, hasRole } = require('keycloak-connect-graphql') | |
const resolvers = { | |
Article: { | |
analytics: hasRole('editor')(articleAnalyticsResolver) | |
}, | |
Query: { | |
listArticles: auth(listArticlesResolver) | |
}, | |
mutation: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const keycloakSubscriptionHandler = new KeycloakSubscriptionHandler({ keycloak }) | |
new SubscriptionServer({ | |
execute, | |
subscribe, | |
schema: server.schema, | |
onConnect: async (connectionParams, websocket, connectionContext) => { | |
const token = await keycloakSubscriptionHandler.onSubscriptionConnect(connectionParams) | |
return { | |
kauth: new KeycloakSubscriptionContext(token) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const resolvers = { | |
Subscription: { | |
commentAdded: { | |
subscribe: () => pubsub.asyncIterator(COMMENT_ADDED) | |
}, | |
messageAdded: { | |
subscribe: auth(() => pubsub.asyncIterator(COMMENT_ADDED)) | |
}, | |
alertAdded: { | |
subscribe: hasRole('admin')(() => pubsub.asyncIterator(ALERT_ADDED)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Keycloak from 'keycloak-js' | |
import { WebSocketLink } from 'apollo-link-ws' | |
var keycloak = Keycloak({ | |
url: 'http://keycloak-server/auth', | |
realm: 'myrealm', | |
clientId: 'myapp' | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloOfflineClient } from 'offix-client'; | |
import { InMemoryCache } from 'apollo-cache-inmemory'; | |
import { HttpLink } from "apollo-link-http"; | |
const config = { | |
link: new HttpLink({ uri: 'http://example.com/graphql' }) | |
cache: new InMemoryCache() | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input CreateNoteInput { | |
id: ID | |
content: String! | |
_version: Int | |
} | |
input CreateTaskInput { | |
id: ID | |
title: String! | |
description: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const authConfig = { | |
Task: { | |
create: {}, | |
read: {}, | |
update: { roles: ["admin"] }, | |
delete: { roles: ["admin"] } | |
}, | |
Report: { | |
create: { roles: ["admin"] }, | |
read: {}, |