Welcome to the Default template for the Composabase local playground. This guide will help you get started with the setup and usage of this on your local environment.
Before you begin, make sure you have cloned your project repository.
SSH:
git clone $REPO_SSH_URLHTTPS:
git clone $REPO_URLNext, install the project dependencies using one of the following commands:
yarnor
npm installTo interact with this template, you need to use the Composabase CLI, which should be installed globally. To install it, run one of the following commands:
yarn global add @composabase/clior
npm install -g @composabase/cliAs the first step, you will need to login to the Composabase Dashboard in your terminal. Use the following command:
composabase loginAfter logging in, next step will fetch the necessary environment variables from the Composabase Dashboard using this command:
composabase pull:envPull GraphQL schema from your Composabase project. This command will create the GraphQL schema file in the @composabase/client directory.
composabase pull:schemaThis step ensures that your local GraphQL schema definitions are up-to-date.
Finally, you can start the local development environment using the following command:
yarn startor
npm run startThis command launches the development server and allows you to begin working with your GraphQL queries and resolvers locally.
If everything went well, you should be able to access the Composabase GraphQL Playground at http://localhost:4000.
As part of this template we added some custom resolvers. You can find them in the src/graphql folder.
This query returns a simple string.
Arguments:
name: StringisImportant: Boolean
You can test it by executing the following query in the GraphQL Playground:
query hello {
hello(name: "John Doe", isImportant: true)
}And will answer with the following response:
{
"data": {
"hello": "Hello John Doe!"
}
}You can find this code example at the followig paths:
- Schema: src/graphql/schema.ts
- Resolver: src/graphql/resolvers/queries/hello.ts
This query returns a simple string
Arguments:
input: MyCustomInputname: StringisImportant: Boolean
You can test it by executing the following query in the GraphQL Playground:
query helloCustom {
helloCustom(input: { name: "Composabase", isImportant: true })
}And will answer with the following response:
{
"data": {
"helloCustom": "Hello Composabase!"
}
}You can find this code example at the followig paths:
- Schema: src/graphql/modules/hello-custom/index.ts
- Resolver: src/graphql/modules/hello-custom/resolvers/queries/hello.ts
Remember that this guide assumes you have basic familiarity with command-line tools and development environments. If you encounter any issues, refer to the Composabase documentation or seek assistance from our support team.
Happy coding!