Skip to content

Commit 7d89452

Browse files
fix: Improves file naming
Swift disallows duplicate file names (even in plugins), so these should be less commonly matched than the previous file names.
1 parent 084f18e commit 7d89452

3 files changed

Lines changed: 10 additions & 18 deletions

File tree

Plugins/GraphQLGeneratorPlugin.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ struct GraphQLGeneratorPlugin: BuildToolPlugin {
2727
let schemaInputs = schemaFiles.map(\.url)
2828

2929
let outputFiles = [
30-
outputDirectory.appendingPathComponent("Types.swift"),
31-
outputDirectory.appendingPathComponent("Schema.swift"),
32-
outputDirectory.appendingPathComponent("SDL.swift"),
30+
outputDirectory.appendingPathComponent("BuildGraphQLSchema.swift"),
31+
outputDirectory.appendingPathComponent("GraphQLRawSDL.swift"),
32+
outputDirectory.appendingPathComponent("GraphQLTypes.swift"),
3333
]
3434

3535
let arguments = schemaInputs.flatMap { ["\($0.path)"] } + [

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ type Query {
5353

5454
### 2. Build Your Project
5555

56-
When you build, the plugin will automatically generate Swift code:
57-
- `Types.swift` - Swift protocols and types for your GraphQL types. These are all namespaced within `GraphQLGenerated`.
58-
- `Schema.swift` - Defines `buildGraphQLSchema` function that builds an executable schema
56+
When you build, the plugin will automatically generate Swift code that you can view in the `.build/plugins/outputs` directory:
57+
- `BuildGraphQLSchema.swift` - Defines `buildGraphQLSchema` function that builds an executable schema.
58+
- `GraphQLRawSDL.swift` - The `graphQLRawSDL` global property, which is a Swift string literal of the input schema. This is internally used at runtime to parse the schema.
59+
- `GraphQLTypes.swift` - Swift protocols and types for your GraphQL types. These are all namespaced within `GraphQLGenerated`.
5960

6061
### 3. Create required types
6162

Sources/GraphQLGeneratorCore/Generator/CodeGenerator.swift

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,9 @@ package struct CodeGenerator {
1111
let schema = try GraphQL.buildSchema(source: source)
1212

1313
var files: [String: String] = [:]
14-
15-
// Generate Types.swift
16-
let typeGenerator = TypeGenerator()
17-
files["Types.swift"] = try typeGenerator.generate(schema: schema)
18-
19-
// Generate Schema.swift
20-
let schemaGenerator = SchemaGenerator()
21-
files["Schema.swift"] = try schemaGenerator.generate(schema: schema)
22-
23-
// Generate SDL.swift
24-
let sdlGenerator = SDLGenerator()
25-
files["SDL.swift"] = try sdlGenerator.generate(source: source)
14+
files["BuildGraphQLSchema.swift"] = try SchemaGenerator().generate(schema: schema)
15+
files["GraphQLRawSDL.swift"] = try SDLGenerator().generate(source: source)
16+
files["GraphQLTypes.swift"] = try TypeGenerator().generate(schema: schema)
2617

2718
return files
2819
}

0 commit comments

Comments
 (0)