Skip to content

Commit

Permalink
TOC generator
Browse files Browse the repository at this point in the history
  • Loading branch information
maticzav committed Feb 15, 2021
1 parent 5d57c98 commit 9934ab2
Show file tree
Hide file tree
Showing 17 changed files with 325 additions and 101 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Generate Table Of Contents

on:
push:
branches:
- main

jobs:
build:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v2
- name: Generate table of contents
run: |
cd scripts
yarn g:tsn index.ts
git commit -am "chore: generate TOC"
git push
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ node_modules

package.tgz

dist
responses/*
!responses/.gitkeep

Expand Down
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,34 @@ You can also run `swift-graphql help` to learn more about options and how it wor
---

<!-- index-start -->

- [Why?](#why)
- [How does it work?](#howdoesitwork)
- [Sending requests](#sendingrequests)
- [Reference](#reference)
- [`send`](#send)
- [`listen`](#listen)
- [`Selection<Type, Scope>`](#selectiontypescope)
- [Nullable, list, and non-nullable fields](#nullablelistandnonnullablefields)
- [Making selection on the entire type](#makingselectionontheentiretype)
- [Mapping Selection](#mappingselection)
- [`Unions`](#unions)
- [`Interfaces`](#interfaces)
- [`OptionalArgument`](#optionalargument)
- [`Codecs` - Custom Scalars](#codecscustomscalars)
- [SwiftGraphQLCodegen](#swiftgraphqlcodegen)
- [`generate`](#generate)
- [F.A.Q](#faq)
- [How do I create a fragment?](#howdoicreateafragment)
- [How do I create an alias?](#howdoicreateanalias)
- [My queries include strange alias. What is that about?](#myqueriesincludestrangealiaswhatisthatabout)
- [How do we populate the values?](#howdowepopulatethevalues)
- [Why do I have to include try whenever I select something?](#whydoihavetoincludetrywheneveriselectsomething)
- [What are the pitfalls in Apollo iOS that you were referring to at the top?](#whatarethepitfallsinapolloiosthatyouwerereferringtoatthetop)
- [Roadmap and Contributing](#roadmapandcontributing)
- [Thank you](#thankyou)
- [License](#license)

<!-- index-end -->

## Why?
Expand Down Expand Up @@ -610,6 +638,6 @@ Thank you! 🙌

---

### License
## License

MIT @ Matic Zavadlal
1 change: 1 addition & 0 deletions Sources/SwiftGraphQLCodegen/Generator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public struct GraphQLCodegen {
/// Generates the code that can be used to define selections.
func generate(schema: Schema) throws -> String {
let code = """
// This file was auto-generated using maticzav/swift-graphql. DO NOT EDIT MANUALLY!
import SwiftGraphQL
// MARK: - Operations
Expand Down
18 changes: 9 additions & 9 deletions Tests/SwiftGraphQLCodegenTests/Generator/FieldTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ final class FieldTests: XCTestCase {
if let data = data.id[field.alias!] {
return data
}
throw SG.HttpError.badpayload
throw HttpError.badpayload
case .mocking:
return String.mockValue
}
Expand Down Expand Up @@ -171,7 +171,7 @@ final class FieldTests: XCTestCase {
if let data = data.ids[field.alias!] {
return data
}
throw SG.HttpError.badpayload
throw HttpError.badpayload
case .mocking:
return []
}
Expand Down Expand Up @@ -210,7 +210,7 @@ final class FieldTests: XCTestCase {
if let data = data.episode[field.alias!] {
return data
}
throw SG.HttpError.badpayload
throw HttpError.badpayload
case .mocking:
return Enums.Episode.allCases.first!
}
Expand Down Expand Up @@ -279,7 +279,7 @@ final class FieldTests: XCTestCase {
if let data = data.episode[field.alias!] {
return data
}
throw SG.HttpError.badpayload
throw HttpError.badpayload
case .mocking:
return []
}
Expand Down Expand Up @@ -321,7 +321,7 @@ final class FieldTests: XCTestCase {
if let data = data.hero[field.alias!] {
return try selection.decode(data: data)
}
throw SG.HttpError.badpayload
throw HttpError.badpayload
case .mocking:
return selection.mock()
}
Expand Down Expand Up @@ -394,7 +394,7 @@ final class FieldTests: XCTestCase {
if let data = data.hero[field.alias!] {
return try selection.decode(data: data)
}
throw SG.HttpError.badpayload
throw HttpError.badpayload
case .mocking:
return selection.mock()
}
Expand Down Expand Up @@ -439,7 +439,7 @@ final class FieldTests: XCTestCase {
if let data = data.hero[field.alias!] {
return data
}
throw SG.HttpError.badpayload
throw HttpError.badpayload
case .mocking:
return String.mockValue
}
Expand Down Expand Up @@ -482,7 +482,7 @@ final class FieldTests: XCTestCase {
if let data = data.hero[field.alias!] {
return data
}
throw SG.HttpError.badpayload
throw HttpError.badpayload
case .mocking:
return String.mockValue
}
Expand Down Expand Up @@ -525,7 +525,7 @@ final class FieldTests: XCTestCase {
if let data = data.hero[field.alias!] {
return data
}
throw SG.HttpError.badpayload
throw HttpError.badpayload
case .mocking:
return String.mockValue
}
Expand Down
Loading

0 comments on commit 9934ab2

Please sign in to comment.