Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intial commit #1

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
*.txt text eol=crlf diff
*.xml text eol=crlf diff
*.xaml text eol=crlf diff
*.dll -text -diff
*.pdb -text -diff
*.zip -text -diff
*.config text eol=crlf diff
*.docx -text -diff
*.sample text eol=crlf diff
*.chm -text -diff
*.jar -text -diff
*.sln text eol=crlf diff
*.vssscc text eol=crlf diff
*.testsettings text eol=crlf diff
*.vsmdi text eol=crlf diff
*.targets text eol=crlf diff
*.bat text eol=crlf diff
*.idx -text -diff
*.pack -text -diff
*.698_20141017 text eol=crlf diff
*.181_20141104 text eol=crlf diff
*.698_20141105 text eol=crlf diff
*.701_20141106 text eol=crlf diff
*.488_20141110 text eol=crlf diff
*.197_20141117 text eol=crlf diff
*.190_20141016 text eol=crlf diff
*.csproj text eol=crlf diff
*.vspscc text eol=crlf diff
*.cs text eol=crlf diff
*.settings text eol=crlf diff
*.Config text eol=crlf diff
*.exe -text -diff
*.aspx text eol=crlf diff
*.vb text eol=crlf diff
*.asax text eol=crlf diff
*.ashx text eol=crlf diff
*.ico -text -diff
*.html text eol=crlf diff
*.vbproj text eol=crlf diff
*.csv text eol=crlf diff
*.loadtest text eol=crlf diff
*.webtest text eol=crlf diff
*.cd text eol=crlf diff
*.jmx text eol=crlf diff
*.css text eol=crlf diff
*.json text eol=crlf diff
*.js text eol=crlf diff
*.XML text eol=crlf diff
*.prefs text eol=crlf diff
*.tsv text eol=crlf diff
*.xlsx -text -diff
*.au3 text eol=crlf diff
*.donotuse -text -diff
*.png -text -diff
*.nupkg -text -diff
*.htm text eol=crlf diff
*.browser text eol=crlf diff
*.exclude text eol=crlf diff
*.gif -text -diff
*.jpg -text -diff
*.mmdb -text -diff
*.myapp text eol=crlf diff
*.resx text eol=crlf diff
*.rb text eol=crlf diff
*.yaml text eol=crlf diff
*.manifest text eol=crlf diff
*.sql text eol=crlf diff
*.markdown text eol=crlf diff
*.launch text eol=crlf diff
*.crx -text -diff
*.xpi -text -diff
*.ps1 text eol=crlf diff
*.ascx text eol=crlf diff
*.master text eol=crlf diff
*.disco text eol=crlf diff
*.discomap text eol=crlf diff
*.wsdl text eol=crlf diff
*.htc text eol=crlf diff
*.pubxml text eol=crlf diff
*.datasource text eol=crlf diff
*.map text eol=crlf diff
*.ts text eol=crlf diff
*.cshtml text eol=crlf diff
*.nuspec text eol=crlf diff
*.pp text eol=crlf diff
*.opts text eol=crlf diff
*.erb text eol=crlf diff
*.pri -text -diff
*.inc text eol=crlf diff
*.db -text -diff
*.html-20090130 text eol=crlf diff
*.Master text eol=crlf diff
*.rej text eol=crlf diff
*.psd -text -diff
*.bmp -text -diff
*.properties text eol=crlf diff
*.task text eol=crlf diff
*.project text eol=crlf diff
*.classpath text eol=crlf diff
*.buildpath text eol=crlf diff
*.java text eol=crlf diff
*.sql encoding=UTF-8
*.cshtml encoding=UTF-8
*.cs encoding=UTF-8
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: .NET Core Build

on:
pull_request:

env:
NETCORE_VERSION: '8.0'
GIT_REPO_ROOT: src
SOLUTION_FILE: Agoda.GrapqhlGen.sln
DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX: 2

jobs:

build:
name: Build Package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core SDK ${{ env.NETCORE_VERSION }}
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.NETCORE_VERSION }}

- name: Restore
working-directory: ${{ env.GIT_REPO_ROOT }}
run: dotnet restore ${{ env.SOLUTION_FILE }}

- name: Build
working-directory: ${{ env.GIT_REPO_ROOT }}
run: dotnet build ${{ env.SOLUTION_FILE }} --configuration Debug --no-restore
95 changes: 95 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: .NET Core Build and Publish

on:
push:

env:
NETCORE_VERSION: '8.0'
GIT_REPO_ROOT: src
MAJOR_MINOR_VERSION: 1.0.
SOLUTION_FILE: Agoda.GrapqhlGen.sln
DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX: 2

jobs:

build:
name: Build Package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core SDK ${{ env.NETCORE_VERSION }}
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.NETCORE_VERSION }}

- name: Restore
working-directory: ${{ env.GIT_REPO_ROOT }}
run: dotnet restore ${{ env.SOLUTION_FILE }}

- name: Build
working-directory: ${{ env.GIT_REPO_ROOT }}
run: dotnet build ${{ env.SOLUTION_FILE }} --configuration Release --no-restore

- name: Pack Release
if: github.ref == 'refs/heads/master'
working-directory: ${{ env.GIT_REPO_ROOT }}
run: dotnet pack ${{ env.SOLUTION_FILE }} --configuration Release -o finalpackage --no-build -p:PackageVersion=${{ env.MAJOR_MINOR_VERSION }}${{ github.run_number }}

- name: Pack Preview
if: github.ref != 'refs/heads/master'
working-directory: ${{ env.GIT_REPO_ROOT }}
run: dotnet pack ${{ env.SOLUTION_FILE }} --configuration Release -o finalpackage --no-build -p:PackageVersion=${{ env.MAJOR_MINOR_VERSION }}${{ github.run_number }}-preview

- name: Publish artifact
uses: actions/upload-artifact@master
with:
name: nupkg
path: ${{ env.GIT_REPO_ROOT }}/finalpackage

deploy:
needs: build
name: Deploy Packages
runs-on: ubuntu-latest
steps:
- name: Download Package artifact
uses: actions/download-artifact@master
with:
name: nupkg
path: ./nupkg

- name: Setup NuGet
uses: NuGet/[email protected]
with:
nuget-api-key: ${{ secrets.KLONDIKE_API_KEY }}
nuget-version: latest

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.NETCORE_VERSION }}

- name: Push to NuGet
run: dotnet nuget push nupkg/**/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://nuget.org --skip-duplicate

release:
needs: deploy
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Create Draft Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.MAJOR_MINOR_VERSION }}${{ github.run_number }}
release_name: ${{ env.MAJOR_MINOR_VERSION }}${{ github.run_number }}
draft: true
prerelease: false

- uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ steps.create_release.outputs.id }}
Empty file added CONTRIBUTING.md
Empty file.
74 changes: 72 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,72 @@
# dotnet-cli-grapqhl-gen
Grapqhl Generation dotnet cli Tool
# dotnet-cli-graphql-gen: GraphQL Code Generation Made Easy!

## Overview

Welcome to dotnet-cli-graphql-gen, an open-source CLI tool that wraps npm package graphql-codegen to add some missing parts.

## Requirements

- .NET 8.0 or higher (Because we believe in staying current!)
- pnpm (Don't worry, we'll install it if you don't have it)

## Installation

### Global Tool Installation

Install it globally (because great tools should be available everywhere):
```bash
dotnet tool install --global Agoda.GrapqhlGen
```

### Local Project Installation

Or keep it project-specific:
```bash
dotnet new tool-manifest # if you haven't already
dotnet tool install Agoda.GrapqhlGen
```

## Quick Start

Generate your GraphQL client code with a single command:

```bash
grapqhlgen \
--schema-url "https://your.graphql.api" \
--input-path "./graphql" \
--output-path "./Generated" \
--namespace "YourCompany.YourProject" \
--headers "API-Key: your-key"
```

## Command Options

- `--schema-url` (Required): URL of your GraphQL schema
- `--input-path` (Required): Directory containing your .graphql files
- `--output-path` (Required): Where to save generated files
- `--namespace` (Optional): Base namespace for generated code (Default: "Generated")
- `--headers` (Optional): Headers for schema request (Format: "Key: Value")
- `--template` (Optional): Code generation template (Default: "typescript")
- `--model-file` (Optional): Name of the generated models file (Default: "Models.cs")
- `--log-level` (Optional): Set logging verbosity (Default: "Information")

## Contributing

We love contributions! Whether you're fixing bugs, improving documentation, or adding new features, check out our [Contributing Guide](CONTRIBUTING.md) for details on getting started.

## Best Practices

- Keep your GraphQL queries in separate .graphql files
- Use meaningful names for your queries and mutations
- Organize your GraphQL files by feature or domain
- Version control your GraphQL files alongside your code

## And Finally...

Remember, in the world of GraphQL, there are two types of developers: those who use code generation tools, and those who wish they had started using them sooner! With dotnet-cli-graphql-gen, you'll never want to write GraphQL client code by hand again.

Happy coding, and may your queries always resolve! 🚀

## License

Apache 2.0 - feel free to use this tool in your projects, whether personal or commercial. Just don't blame us if your GraphQL queries start writing themselves! 😉
26 changes: 26 additions & 0 deletions src/Agoda.GrapqhlGen.Tests/Agoda.GrapqhlGen.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Agoda.Analyzers" Version="1.1.83" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Agoda.GrapqhlGen\Agoda.GrapqhlGen.csproj" />
</ItemGroup>

</Project>
Loading
Loading