-
Notifications
You must be signed in to change notification settings - Fork 14
Initial setup
The initial setup:
# create console app
dotnet new console -o QLClient
# go to project folder
cd QLClient
# create manifest file to track nuget tools
dotnet new tool-manifest
# add ZeroQL.CLI nuget tool
dotnet tool install ZeroQL.CLI
# add ZeroQL nuget package
dotnet add package ZeroQL
# fetch graphql schema from server(creates schema.graphql file)
dotnet zeroql schema pull --url http://localhost:10000/graphql
# to create ZeroQL config file: ./config.zeroql.json
dotnet zeroql config init
# build the project to initiate the ZeroQL client generation with options specified inside config.zeroql.json
dotnet build
The build should be successful, and now we can use the generated client.
The command dotnet zeroql config init
creates the config.zeroql.json
. By itself it looks like that:
{
"$schema": "https://raw.githubusercontent.com/byme8/ZeroQL/main/schema.verified.json",
"graphql": "./schema.graphql",
"namespace": "ZeroQL.Client",
"clientName": "ZeroQLClient"
}
Now if you have ZeroQL
package installed to your csproj
, it will automatically detect and execute CLI based on this configuration file on every build. To make sure that it works, the config file should follow the *.zeroql.json
pattern, or you can add a custom definition in your csproj
like that:
<ItemGroup>
<ZeroQLConfig Include="you.custom.config.name.json"/>
</ItemGroup>
The generated client would be stored inside ./obj/ZeroQL
folder. So it will never appear in the solution. However, you still have access to generated classes in your source code.
If you want to turn off automatic generation on every build, it is possible to disable it:
<PropertyGroup>
<ZeroQLOnBuildTriggerEnabled>False</ZeroQLOnBuildTriggerEnabled>
</PropertyGroup>