Comments (9)
Good content on Babel plugins: https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md
from create-graphql.
Yep, I think so, we need to define the inputs and outputs of each plugin
from create-graphql.
First draft of Plugins
Read Database Schema Plugins
Motivation
A read schema plugin should read a schema (collection/table definition) and return an object describing it.
Examples
- create-graphql-mongoose
- create-graphql-mysql
- create-graphql-postgres
- create-graphql-rethinkdb
Templates Plugins
Motivation
CreateGraphql should output a different file for a different option provided, for instance: output a raw mutation or a relay mutation
Examples
- create-graphql-type-raw
- create-graphql-type-relay
- create-graphql-mutation-raw
- create-graphql-mutation-relay
we need to define inputs and outputs of these plugins
from create-graphql.
I can imagine it to handle schema from multiple types of databases but how would that be for different templates?
from create-graphql.
Also, how do you plan on starting, should #43 wait for it?
Turning the mongoose
schema reading into a plugin should be really straightforward.
We should also have a plugins
property on .graphqlrc
.
from create-graphql.
A template plugin could have an option parameter, like -t for template
from create-graphql.
A template plugin could have an option parameter, like -t for template
@sibelius: what do you mean?
I meant, how will we implement a template plugin? Will we prepare all the variables, pass it to the plugin and it will return the files?
from create-graphql.
So, I started working on this, I thought the following as a blueprint for a create-graphql-plugin
:
export default {
pre: (arguments) => {
const {
config, // The content of `.graphqlrc`, will be the default if it doesn't exist
} = arguments;
console.log('this is a pre hook function');
return {
fields, // The fields generated on the plugin
files, // Array of objects, e.g.: [{ name: 'ExampleAddMutation.js', content: 'Content of file }]
};
},
post: (arguments) => {
const {
config, // The content of `.graphqlrc`, will be the default if it doesn't exist,
fields, // The fields of the schema
} = arguments;
console.log('this is a post hook function');
return {}; // What would this return?
},
};
Would love your opinions on this, @sibelius & @felippepuhle.
Also, the plugins would be installed as a devDependency
and specified on .graphqlrc
under plugins
, e.g.:
{
"directories": {
...
"connection": "connection",
"loader": "loader",
"model": "model",
...
},
"plugins": [
"create-graphql-plugin-mongoose",
"create-graphql-plugin-sequelize",
...
]
}
The generator would then call each plugin based on the order defined, so it would call the mongoose one and then sequelize with the results brought from mongoose.
Still have to figure out how we will deal with files.
from create-graphql.
https://github.com/thejameskyle/babel-file
from create-graphql.
Related Issues (20)
- Creating a New Project Settings HOT 5
- UPDATE on npm HOT 2
- Updating create-graphql breaks other projects HOT 1
- Relay Modern frontend templates
- Update Loader templates
- Clone boilerplate using a tag HOT 12
- Dockerizing environment HOT 3
- Hygen refactor
- throw error while generating type and mutation base on mongoose schema HOT 2
- Update builds to .circleci
- Integrate with plugin based system for dev to extend create-graphql
- Improve documentation by adding new methods and capabilities
- update generated files HOT 4
- add support for array field on mongoose HOT 4
- Use yarn on Lerna
- permit local installations HOT 3
- object notation should be optional HOT 2
- upgrade Loader templates HOT 1
- Update templates to handle ConnectionFromMongoCursor breaking change
- update loader templates
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 create-graphql.