graphile / graphile/graphile.github.io

Inconsistent plugins development documentation

Abierto
#255 10 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
SCSS
Estrellas
27
Forks
126
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I'm trying to add a custom plugin to the `postgraphile:http:handler` event.
Accordint to the https://www.graphile.org/postgraphile/plugins/#enabling-via-postgraphilercjs section, I'm adding it to the `plugins` rc file section.
According to the https://www.graphile.org/postgraphile/plugins/#writing-your-own-plugins section, I've created my plugin stub:
```
const CorsPlugin = {
['postgraphile:http:handler'] (req, p2) {
console.log(req);
console.log(p2);
return req;
}
}
module.exports = CorsPlugin
```
But when running, I'm getting the following error log:
```
/postgraphile/build-turbo/postgraphile/cli.js:300
throw new Error(`No plugin found matching spec '${name}' - expected function, found '${typeof plugin}'`);
^
Error: No plugin found matching spec '/postgraphile/CorsPlugin' - expected function, found 'object' at /postgraphile/build-turbo/postgraphile/cli.js:300:19
```

Please update these docs on how to write own plugins.

Also, there's no documentation on how to use the existing CORS plugin example with the rc file to be able to adapt it to my needs. Plugins documentation is overall messy and it's hard to understand what's going on and how to catch anything without a long time googling, discord discussions, or github issues.

My main pain points during all my Postgraphile experience are:

1. What type of plugins exists?
2. What's the difference between plugin types?
3. How plugins and hooks relate?
4. What types of hooks exist?
5. Which hooks can be set up from which plugins?
6. Where to see plugins and hooks parameters documentation?
7. How to convert plugins and hooks declaration/connection between different types (middleware, library, rc file, CLI)? If I found an example of a plugin/hook I spend a lot of time trying to adapt it to rc file.
8. When I see a comment like `use postgraphile:http:handler to intercept the result if it's for us` used by Benjie everywhere I see a wall of hours of investigations how to implement it in the reality. Especially in my deployment way (with an rc file).
9. A single entrypoint of plugins/hooks documentation with a clear table of contents would be very useful. Like this: https://www.easypost.com/docs/api . Examples of plugins with the different types of connection (library/rc file/cli) like code examples in different languages also would be super useful (here https://www.easypost.com/docs/api it is implemented as a dropdown list, some sites use tabs: https://cloud.google.com/tasks/docs/reference/rest/v2/projects.locations.queues.tasks/run).

I like Postgraphile a lot, but every time I need to do something by my own plugins I feel pain... :(

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Start with the linked “Enabling via postgraphilerc.js” and “Writing your own plugins” sections, then reproduce the reported object-versus-function error using the shown CorsPlugin example. Done means the plugin documentation explains plugin and hook types, their parameters and relationships, and provides clear library, rc-file, and CLI examples, including the existing CORS plugin.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript
Área
documentation
Tipo de issue
Documentación
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
20/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.