You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(appsync): support query & mutation generation for code-first approach (#9992)
Implemented methods in `appsync.Schema` to easily generate query/mutation fields, or bind an existing `ObjectType` as the top level query/mutation type.
Fixes: #9308Fixes: #9310
----
*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
CDK offers the ability to generate your schema in a code-first approach.
231
231
A code-first approach offers a developer workflow with:
@@ -235,7 +235,7 @@ A code-first approach offers a developer workflow with:
235
235
236
236
The code-first approach allows for **dynamic** schema generation. You can generate your schema based on variables and templates to reduce code duplication.
237
237
238
-
### Code-First Example
238
+
####Code-First Example
239
239
240
240
To showcase the code-first approach. Let's try to model the following schema segment.
@@ -353,7 +351,7 @@ create the base Object Type (i.e. Film) and from there we can generate its respe
353
351
354
352
Check out a more in-depth example [here](https://github.com/BryanPan342/starwars-code-first).
355
353
356
-
### GraphQL Types
354
+
####GraphQL Types
357
355
358
356
One of the benefits of GraphQL is its strongly typed nature. We define the
359
357
types within an object, query, mutation, interface, etc. as **GraphQL Types**.
@@ -369,12 +367,12 @@ More concretely, GraphQL Types are simply the types appended to variables.
369
367
Referencing the object type `Demo` in the previous example, the GraphQL Types
370
368
is `String!` and is applied to both the names `id` and `version`.
371
369
372
-
### Field and Resolvable Fields
370
+
####Field and Resolvable Fields
373
371
374
372
While `GraphqlType` is a base implementation for GraphQL fields, we have abstractions
375
373
on top of `GraphqlType` that provide finer grain support.
376
374
377
-
#### Field
375
+
#####Field
378
376
379
377
`Field` extends `GraphqlType` and will allow you to define arguments. [**Interface Types**](#Interface-Types) are not resolvable and this class will allow you to define arguments,
380
378
but not its resolvers.
@@ -401,7 +399,7 @@ const type = new appsync.InterfaceType('Node', {
401
399
});
402
400
```
403
401
404
-
#### Resolvable Fields
402
+
#####Resolvable Fields
405
403
406
404
`ResolvableField` extends `Field` and will allow you to define arguments and its resolvers.
407
405
[**Object Types**](#Object-Types) can have fields that resolve and perform operations on
@@ -463,7 +461,7 @@ const query = new appsync.ObjectType('Query', {
463
461
464
462
Learn more about fields and resolvers [here](https://docs.aws.amazon.com/appsync/latest/devguide/resolver-mapping-template-reference-overview.html).
465
463
466
-
### Intermediate Types
464
+
####Intermediate Types
467
465
468
466
Intermediate Types are defined by Graphql Types and Fields. They have a set of defined
469
467
fields, where each field corresponds to another type in the system. Intermediate
@@ -473,7 +471,7 @@ Intermediate Types include:
473
471
-[**Interface Types**](#Interface-Types)
474
472
-[**Object Types**](#Object-Types)
475
473
476
-
### Interface Types
474
+
#####Interface Types
477
475
478
476
**Interface Types** are abstract types that define the implementation of other
479
477
intermediate types. They are useful for eliminating duplication and can be used
@@ -488,7 +486,7 @@ const node = new appsync.InterfaceType('Node', {
488
486
});
489
487
```
490
488
491
-
### Object Types
489
+
#####Object Types
492
490
493
491
**Object Types** are types that you declare. For example, in the [code-first example](#code-first-example)
494
492
the `demo` variable is an **Object Type**. **Object Types** are defined by
@@ -565,3 +563,48 @@ You can create Object Types in three ways:
0 commit comments