A GraphQL helper to deal with GraphQL requirements. Written with Go 1.19
💾 Caching
🆘 White Listing
And other features will be supported by GoQL.
You should create a GoQL instance at the beginning with using function
gq := goql.New()
There are some functions for initialization of GoQL instance.
- ConfigureDB
- ConfigureInmemoryCache
- ConfigureRedisCache
- UseWhitelister
- UseGQLCacher
Database configuration is done by ConfigureDB function. It takes 2 parameters to configure database.
- Database name (Such as postgres,mysql)
- Database instance (pointer of sql.DB)
🆘 For now, postgres is the only supported db. However, mysql, mssql and other most known database systems will be integrated to GoQL.
gq.ConfigureDB(constants.POSTGRES, db)
Set your migration files directory as environment variable called MIGRATION_DIR. Then run
migrations.MigratePostgres(db)
Required migration files can be found inside migrations folder. Migration files depends on database.
Cache configuration is done by ConfigureInmemoryCache and ConfigureRedisCache functions.
gq.ConfigureInmemoryCache()
gq.ConfigureRedisCache(client)
For caching GQL queries, you should run UseGQLCacher function. It returns Cacher and error.
🚨 Database and cache configuration is mandatory to use this feature.
cacher,err := gq.UseGQLCacher()
For whitelisting, you should run UseWhitelister function. It returns Whitelister interface and error.
🚨 Database and cache configuration is mandatory to use this feature.
🚨 Database migration is mandatory to use whitelister
query, err := query.Parse("a gql query")
parses string query to ast.Document.
There are some basic functions to get some specific data along query such as.
queryName := query.Name()
There will be more different helper functions for GQL Operations.
Run all tests
make test
Run single test
make test t="test_to_run"
Run code coverate
make test-coverage
Beside calculating code coverage, it replace code coverage badge on README.md.