Skip to content

Commit c0e78d1

Browse files
authored
Merge pull request #181 from ThinkDeepTech/hm/collect-data
2 parents 7e784c3 + 69d04df commit c0e78d1

File tree

7 files changed

+92
-10
lines changed

7 files changed

+92
-10
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# graphql-binding
2+
3+
TODO: Update with usage example, remove deprication
4+
5+
# Deprecation Notice!
6+
7+
In the last few months, since [the transition of many libraries](https://www.prisma.io/blog/the-guild-takes-over-oss-libraries-vvluy2i4uevs) under [The Guild](http://the-guild.dev)'s leadership, We've reviewed and released many improvements and versions to [graphql-cli](https://github.com/Urigo/graphql-cli), [graphql-config](https://github.com/kamilkisiela/graphql-config) and [graphql-import](https://github.com/ardatan/graphql-import).
8+
9+
We've reviewed `graphql-binding`, had many meetings with current users and engaged the community also through the [roadmap issue](https://github.com/dotansimha/graphql-binding/issues/325).
10+
11+
What we've found is that the new [GraphQL Mesh](https://the-guild.dev/blog/graphql-mesh) library is covering not only all the current capabilities of GraphQL Binding, but also the future ideas that were introduced in the [original GraphQL Binding blog post](https://github.com/prisma-archive/prisma-blog-archive/blob/master/2018-01-12-reusing-and-composing-graphql-apis-with-graphql-bindings.mdx) and haven't come to life yet.
12+
13+
And the best thing - [GraphQL Mesh](https://the-guild.dev/blog/graphql-mesh) gives you all those capabilities, even if your source is not a GraphQL service at all!
14+
it can be GraphQL, OpenAPI/Swagger, gRPC, SQL or any other source!
15+
And of course you can even merge all those sources into a single SDK.
16+
17+
Just like GraphQL Binding, you get a fully typed SDK (thanks to the protocols SDKs and the [GraphQL Code Generator](https://github.com/dotansimha/graphql-code-generator)), but from any source, and that SDK can run anywhere, as a connector or as a full blown gateway.
18+
And you can share your own "Mesh Modules" (which you would probably call "your own binding") and our community already created many of those!
19+
Also, we decided to simply expose regular GraphQL, so you can choose how to consume it using all the awesome [fluent client SDKs out there](https://hasura.io/blog/fluent-graphql-clients-how-to-write-queries-like-a-boss/).
20+
21+
If you think that we've missed anything from GraphQL Binding that is not supported in a better way in GraphQL Mesh, please let us know!
22+
23+
## Overview
24+
25+
🔗 GraphQL bindings are **modular building blocks** that allow to embed existing GraphQL APIs into your own GraphQL server. Think about it as turning (parts of) GraphQL APIs into reusable LEGO building blocks. Bindings may be generated in JavaScript, TypeScript, or Flow.
26+
27+
> The idea of GraphQL bindings is introduced in detail in this blog post: [Reusing & Composing GraphQL APIs with GraphQL Bindings](https://www.prisma.io/blog/reusing-and-composing-graphql-apis-with-graphql-bindings-80a4aa37cff5/)
28+
29+
## Install
30+
31+
```sh
32+
yarn add graphql-binding
33+
```
34+
35+
## Public GraphQL bindings
36+
37+
You can find practical, production-ready examples here:
38+
39+
- [`graphql-binding-github`](https://github.com/graphql-binding/graphql-binding-github)
40+
- [`prisma-binding`](https://github.com/prisma/prisma-binding)
41+
42+
> Note: If you've created your own GraphQL binding based on this package, please add it to this list via a PR 🙌
43+
44+
If you have any questions, share some ideas or just want to chat about GraphQL bindings, join the [`#graphql-bindings`](https://prisma.slack.com/messages/graphql-bindings) channel in our [Slack](https://slack.prisma.io/).

packages/deep-microservice-collection/src/datasource/tweet-store.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TweetStore extends MongoDataSource {
1919
const result = await this.collection.find({
2020
economicEntityName: economicEntityName.toLowerCase(),
2121
economicEntityType : economicEntityType.toLowerCase()
22-
}).limit(numTweetsToReturn).sort({timestamp: -1}).toArray();
22+
}).sort({timestamp: -1}).limit(numTweetsToReturn).toArray();
2323

2424
return this._reduceTweets(result);
2525
} catch (e) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const debounce = (fcn, wait) => {
2+
3+
let timeout;
4+
5+
return function execute (...args) {
6+
7+
const later = () => {
8+
clearTimeout(timeout);
9+
fcn(...args)
10+
};
11+
12+
clearTimeout(timeout);
13+
timeout = setTimeout(later, wait);
14+
};
15+
};
16+
17+
export { debounce };

packages/deep-template-analyzer/deep-analyzer-page-summary.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
import {ApolloMutationController} from '@apollo-elements/core';
12
import {ApolloQuery, html} from '@apollo-elements/lit-apollo';
23
import '@google-web-components/google-chart';
34
import '@thinkdeep/deep-button/deep-button.mjs';
45
import '@thinkdeep/deep-card/deep-card.mjs';
56
import '@thinkdeep/deep-textbox/deep-textbox.mjs';
7+
import {debounce} from './debounce.mjs';
68
import {translate} from 'lit-element-i18n';
9+
import CollectEconomicData from './graphql/CollectEconomicData.mutation.graphql';
710
import GetSentiment from './graphql/GetSentiment.query.graphql';
811

912
export default class DeepAnalyzerPageSummary extends ApolloQuery {
1013
static get properties() {
1114
return {
15+
mutation: {type: Object},
1216
selectedSentiments: {type: Array},
1317
};
1418
}
@@ -23,6 +27,8 @@ export default class DeepAnalyzerPageSummary extends ApolloQuery {
2327
economicEntityType: 'BUSINESS',
2428
};
2529

30+
this.mutation = new ApolloMutationController(this, CollectEconomicData);
31+
2632
this.selectedSentiments = [];
2733
}
2834

@@ -41,13 +47,13 @@ export default class DeepAnalyzerPageSummary extends ApolloQuery {
4147
render() {
4248
return html`
4349
${translate('translations:startCollectingLabel')}
44-
<deep-textbox placeholder="Business Name (i.e, Google)"></deep-textbox>
45-
<deep-button @click="${this._collectData}">Collect Data</deep-button>
46-
47-
${translate('translations:selectBusinessLabel')}
48-
<select name="business" id="business">
49-
<option value="Google">Google</option>
50-
</select>
50+
<deep-textbox
51+
placeholder="i.e, Google"
52+
@input="${debounce(this._setCompanyName.bind(this), 350)}"
53+
></deep-textbox>
54+
<deep-button @click="${() => this.mutation.mutate()}"
55+
>${translate('translations:startButtonLabel')}</deep-button
56+
>
5157
5258
<google-chart
5359
type="line"
@@ -106,6 +112,14 @@ export default class DeepAnalyzerPageSummary extends ApolloQuery {
106112
sentiment.score === selectedPoint[1]
107113
);
108114
}
115+
116+
_setCompanyName({explicitOriginalTarget}) {
117+
const companyName = explicitOriginalTarget.value;
118+
this.mutation.variables = {
119+
economicEntityName: companyName,
120+
economicEntityType: 'BUSINESS',
121+
};
122+
}
109123
}
110124

111125
customElements.define('deep-analyzer-page-summary', DeepAnalyzerPageSummary);
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
mutation CollectEconomicData($economicEntityName: String!, $economicEntityType: EconomicEntityType!){
2+
collectEconomicData(economicEntityName: $economicEntityName, economicEntityType: $economicEntityType) {
3+
success
4+
}
5+
}

packages/deep-template-analyzer/locales/en-CA/common.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default {
1717
headline: 'Explore data.',
1818
buttonText: 'Log In',
1919
notFoundPageContent: 'Page Not Found!',
20-
startCollectingLabel: 'Collect',
20+
startCollectingLabel: 'Collect Business Data',
21+
startButtonLabel: 'Start',
2122
selectBusinessLabel: 'Select a business',
2223
};

packages/deep-template-analyzer/locales/en-US/common.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export default {
1515
headline: 'Something different here',
1616
buttonText: 'Log In',
1717
notFoundPageContent: 'Page Still not found!',
18-
startCollectingLabel: 'Collect2',
18+
startCollectingLabel: 'Collect Business Data2',
19+
startButtonLabel: 'Start2',
1920
selectBusinessLabel: 'Select a business2',
2021
};

0 commit comments

Comments
 (0)