graphile / issues Goto Github PK
View Code? Open in Web Editor NEWIssue management for supporter/pro plugins, etc
Issue management for supporter/pro plugins, etc
I'm encountering an error when running the server using the docker image with the pro plugin enabled (it runs fine using the CLI)
Minimal docker example:
docker run -it --entrypoint ash --network="host" graphile/postgraphile:v4.6.0
# === > (inside container)
yarn add @graphile/pro
export GRAPHILE_LICENSE=<GRAPHILE_LICENSE>
./cli.js --plugins @graphile/pro -c <CONNECTION_URL>
Any request to the server (including graphiql introspection) then yields a version of this error message:
Error: Cannot use GraphQLScalarType "Boolean" from another module or realm.
Ensure that there is only one instance of "graphql" in the node_modules directory. If different versions of "graphql" are the dependencies of other relied on modules, use "resolutions" to ensure only one version is installed.
https://yarnpkg.com/en/docs/selective-version-resolutions
Duplicate "graphql" modules cannot be used at the same time since different versions may have different capabilities and behavior. The data from one version used in the function from another could produce confusing and spurious results.
Originally posted on discord: https://discordapp.com/channels/489127045289476126/697954986461495346/732601497334054913
When using subscriptions through GraphQL, you usually want to read from the main DB instance so you can get the freshest data available. However as an application scales this can put significant stress on the main DB.
Currently, PostGraphile allows you to provide a readOnlyConnection
parameter that will send all query
requests to it which is just fantastic! If the underlying query in a subscription could be also directed towards a read replica that would really help scale this out for larger applications.
I was thinking something along these lines:
select pg_last_xact_replay_timestamp();
returns a timestamp that is >= when the subscription triggered.pg_last_xact_replay_timestamp
(maybe exponential backoff?)Currently in prod, we have clients that are being streamed updated data from the API via subscriptions. As the number of the clients grows more reads are coming from the main DB than the RR which is causing significant performance issues.
I [tick all that apply]:
I'm submitting a ...
It would be nice if the @graphile/supporter
plugin shipped with TypeScript definitions, including a module augmentation on PostGraphileOptions
to include Pro plugin options.
I think the declaration file would need to look something like this:
// index.d.ts
import { PostGraphilePlugin } from 'postgraphile';
declare const plugin: PostGraphilePlugin;
export default plugin;
declare module 'postgraphile' {
export interface PostGraphileOptions {
simpleSubscriptions?: boolean;
readOnlyConnection?: boolean;
defaultPaginationLimit?: number;
graphqlDepthLimit?: number;
graphqlCostLimit?: number;
exposeGraphQLCost?: boolean;
}
}
defaultPaginationCap
in overrideOptionsForRequest
is not taken into account.
I use this config of Graphile Pro:
postgraphile( dbUrl, schemaName, {
defaultPaginationCap: -1,
graphqlDepthLimit: -1,
graphqlCostLimit: -1,
exposeGraphQLCost: false,
overrideOptionsForRequest(req) {
return {
defaultPaginationCap: 2,
graphqlDepthLimit: 2,
graphqlCostLimit: 10000,
exposeGraphQLCost: false
};
}
});
More generally, the defaultPaginationCap
returned by overrideOptionsForRequest
is never taken into account. But the defaultPaginationCap
from the config is well-enforced correctly.
We use quite a lot of plugins, but I don't see anything that would interfere with that. Especially knowing that defaultPaginationCap
from config is well-enforced.
Using @graphile/[email protected]
and [email protected]
and [email protected]
No idea since the plugin is not open source, and the minified code is not so easy to debug 😬
v1.0.0, does not declare postgraphile as a peerDependency in package.json, but it does import postgraphile at some point.
Importing a package that is not declared as a dep or peerDeep is not good, and yarn v2 is especially strict about that.
I had to use the workaround of adding these lines to my .yarnrc/yml
packageExtensions:
"@graphile/pro@*":
peerDependencies:
postgraphile: "*"
Easy fix is to just add postgraphile as a peerDep in package json
Use yarn v2 to install a server with postgraphile + @graphile/pro
Works
Yarn complains that @graphile/pro tries to import postgraphile without defining it in dependencies
Add this to package.json of @graphile/pro
"peerDependencies": {
"postgraphile": "*"
}
I'm using Simple Subscriptions feature. If i set pgStrictFunctions
is true
, relatedNode
return null
. What should I do to use both of these features?
graphileBuildOptions: {
pgStrictFunctions: true,
}
{
"data": {
"listen": {
"relatedNodeId": "WyJwZW9wbGUiLDJd",
"relatedNode": null
}
}
}
If we could put a comment on a table or a foreign key constraint that would hint to the cost calculator what estimate it should use as the number of rows to be returned when a limit isn't specified in the query, it would allow the schema developer to provide a more streamlined experience to their users.
Having the ability to force users to specify a limit on very big tables works great, however, if you know the table is small and it won't return a lot of rows, then forcing the user to still specify a limit makes for a slightly clunkier experience for them. If we don't force them, then the calculated cost for the query is 1000 which is likely too high since we didn't force limits since we know there aren't that many rows to be returned.
At a minimum level, having the following comment would help:
maxRowEstimate -- Tells the calculator how many rows the dev expects would be returned if the user did not specify a limit. Can be put on a table, or on a foreign key constraint. If the relation is being hit via a link in the graph, the constraint value would take precedence, and if it isn't specified, fall back to the table value.
I imagine we could probably get fancier and try to tap into the pg stats, but while that would be fun, it would probably be a lot more complicated to figure out.
We would like to allow different cost limits for different tiers of users.
Right now, the setting is a validation rule, so we can't dynamically change it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.