Comments (19)
We've not released this to npm yet (it's still at the proof-of-concept stage); if you want to try it out copy these files into your project and require index.js
directly:
https://github.com/graphile/pg-aggregates/tree/master/src
What aggregates are you looking for? You may also wish to track graphile/graphile-engine#465
from pg-aggregates.
Thank you for the tip, I will have a look at graphile-engine and follow the updates of this repo.
from pg-aggregates.
@Murthy10 The aggregates are added directly to the connection, your query tries to query it on the nodes
. If you use a tool like GraphiQL it should help you to construct your query with typeahead and linting.
Try:
{
allPayments {
aggregates{
sum {
amount
}
}
}
}
from pg-aggregates.
Is there any way to get this to work with the CLI in the docker image?
from pg-aggregates.
There's no instructions on how to do that as it's not officially released yet. You'd do it the same way - add the files to the docker image and then tell PostGraphile where to find them.
from pg-aggregates.
I'm having some issue when added files from https://github.com/graphile/pg-aggregates/tree/master/src and required index.td
directly.
How I`m doing:
import AggregatePlugin from "./_common/graphql/plugins/pg-aggregates"
...
const buildServer = async () => {
const connection = await connectionPromise
const pgPool = (connection?.driver as any).master
const { schema: graphileSchema, plugin } = await makeSchemaAndPlugin(
pgPool,
schemas, // PostgreSQL schema to use
{
dynamicJson: true,
appendPlugins: [ConnectionFilterPlugin],
graphiql: true,
enhanceGraphiql: true,
watchPg: true,
jwtSecret: getConfig().PasswordHash,
// jwtPgTypeIdentifier: 'public.jwt_token',
pgDefaultRole: 'postgres',
allowExplain: true
}
)
return new ApolloServer({
schema: mergeSchemas({
schemas: [graphileSchema, schema],
}),
plugins: [queryComplexityPlugin, AggregatePlugin, plugin],
context: async ({ event, context: lambdaContext }) => {
const requestId = lambdaContext.awsRequestId
const container = Container.of(requestId)
await connectionPromise
const authorizerContent = event.requestContext?.authorizer
const graphQLContext: Partial<OSContext> = {
uid: authorizerContent?.uid,
userRole: authorizerContent?.userRole,
requestId,
container,
}
return graphQLContext
},
...
I'm sewing two schemas and giving priority to the one generated by the postgraphile. However, when trying to generate the schema I'm taking:
TypeError: Cannot read property 'hook' of undefined
That 'hook' should be a property of 'build' on AddAggregatesPlugin
. @benjie would you help me? Am I forgetting to set up something?
from pg-aggregates.
Try updating all your graphile-related software, it's possible your dependencies are out of date and don't support this yet.
from pg-aggregates.
This is now an official released plugin; usage instructions are in the README 👍
from pg-aggregates.
@benjie I am getting error in graphiql -
query{
allBrands(orderBy: PRICE_DESC){
aggregates{
sum{
price
}
}
}
allSales(orderBy: QUANTITY_DESC, first: 2){
totalCount
nodes{
quantity
brandByBrandId{
brandname
price
productByProductId{
productname
}
}
storeByStoreId{
storename
}
}
aggregates{
sum{
quantity
}
}
}
}
Output
{
"errors": [
{
"message": "Cannot read property '@aggregates' of undefined",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"allBrands",
"aggregates"
]
}
],
"data": {
"allBrands": {
"aggregates": null
},
"allSales": {
"totalCount": 11,
"nodes": [
{
"quantity": 12,
"brandByBrandId": {
"brandname": "Brand E",
"price": "500.50",
"productByProductId": {
"productname": "Product C"
}
},
"storeByStoreId": {
"storename": "Store C"
}
},
{
"quantity": 9,
"brandByBrandId": {
"brandname": "Brand C",
"price": "300.50",
"productByProductId": {
"productname": "Product A"
}
},
"storeByStoreId": {
"storename": "Store B"
}
}
],
"aggregates": {
"sum": null
}
}
}
}
from pg-aggregates.
Requires PostGraphile v4.12.0-alpha.0 or higher.
from pg-aggregates.
Yes, I am using -
"dependencies": {
"@graphile-contrib/pg-simplify-inflector": "^6.1.0",
"db-migrate": "^0.11.12",
"db-migrate-pg": "^1.2.2",
"postgraphile": "^4.12.0-alpha.0",
"@graphile/pg-aggregates": "^0.1.0"
}
from pg-aggregates.
Interesting; try npx yarn-deduplicate && yarn
and then try again. If you're using npm
try switching to yarn
from pg-aggregates.
@benjie FYI, I dockerized a PostGraphile app by following steps in https://www.graphile.org/postgraphile/running-postgraphile-in-docker/
from pg-aggregates.
Output in graphiql -
from pg-aggregates.
Please file an issue about these unexpected nulls, sending through the details (e.g. DB schema/data) as text that can be copied/pasted.
from pg-aggregates.
Hi @benjie ,
I face this issue "Cannot read property '@Aggregates' of undefined"
My dependencies are:
"@graphile/pg-aggregates": "^0.1.0",
"cluster": "^0.7.7",
"compression": "^1.7.4",
"consul": "^0.40.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"nodemon": "^2.0.4",
"pg": "^8.6.0",
"pm2": "^4.5.4",
"postgraphile": "^4.11.0",
"postgraphile-plugin-connection-filter": "^2.2.1",
"sequelize": "^6.6.2"
I changed the postgraphile version to "4.12.0". Also comes the same error.
from pg-aggregates.
Requires PostGraphile v4.12.0-alpha.0 or higher.
-- https://github.com/graphile/pg-aggregates#usage
I don't think you have a new enough version installed. Try yarn add postgraphile@next
.
from pg-aggregates.
Thanks @benjie for the response.
I have solved the above problem.
I want to grouping "data_configuration" which has the same group a or b . I am attached db details for your reference
And in my graphiql interface how i will group object. My graphiql interface is looks like
from pg-aggregates.
You need to request subfields via a selection set on the grouped aggregates field.
from pg-aggregates.
Related Issues (16)
- graphile-build:warn TypeError: getComputedColumnDetails is not a function HOT 1
- Aggregates provide null values HOT 5
- aggregates throwing "null" all the time HOT 1
- TIMESTAMP_TRUNCATED_TO_MONTH & TIMESTAMP_TRUNCATED_TO_YEAR HOT 23
- Cannot get the given example to work HOT 3
- Filtering by totalCount HOT 3
- Getting - Error: Option 'appendPlugins' should be an array of functions, found 'object' at index 0 HOT 3
- Looks like aggregate order bys get generated even when table is omitted HOT 1
- GroupBy computed columns not generated ? HOT 4
- Aggregates ignore ordering HOT 6
- Removing limitation of stringified `keys` HOT 3
- Order by totalCount with per-query custom filtering applied HOT 2
- Aggregates can return unsafe integers HOT 8
- Add relation aggregates to aggregates HOT 6
- getComputedColumnDetails is not a function HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pg-aggregates.