Skip to content

Commit

Permalink
chore(docs): [deploy_website] (#1857)
Browse files Browse the repository at this point in the history
add more type merging config options
  • Loading branch information
yaacovCR committed Jul 31, 2020
1 parent 412345f commit ffb642b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/loaders/url/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export interface LoadFromUrlOptions extends SingleFileOptions, Partial<Introspec

/**
* This loader loads a schema from a URL. The loaded schema is a fully-executable,
* remote schema since it's created using [@graphql-tools/wrap](remote-schemas).
* remote schema since it's created using [@graphql-tools/wrap](/docs/remote-schemas).
*
* ```
* const schema = await loadSchema('http://localhost:3000/graphql', {
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/src/makeExecutableSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { IExecutableSchemaDefinition } from './types';
*
* The `resolvers` object should be a map of type names to nested object, which
* themselves map the type's fields to their appropriate resolvers.
* See the [Resolvers](resolvers) section of the documentation for more details.
* See the [Resolvers](docs/resolvers) section of the documentation for more details.
*
* ```js
* const resolvers = {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/api/modules/_schema_src_index_.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ const typeDefs = gql`

The `resolvers` object should be a map of type names to nested object, which
themselves map the type's fields to their appropriate resolvers.
See the [Resolvers](resolvers) section of the documentation for more details.
See the [Resolvers](/resolvers) section of the documentation for more details.

```js
const resolvers = {
Expand Down
11 changes: 8 additions & 3 deletions website/docs/schema-stitching.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ Batch delegation may be preferable over plain delegation whenever possible, as i

## Using with Transforms

Often, when creating a GraphQL gateway that combines multiple existing schemas, we might want to modify one of the schemas. The most common tasks include renaming some of the types, and filtering the root fields. By using [transforms](/docs/schema-transforms/) with schema stitching, we can easily tweak the subschemas before merging them together. (In earlier versions of graphql-tools, this required an additional round of delegation prior to merging, but transforms can now be specifying directly when merging using the new subschema configuration objects.)
Often, when creating a GraphQL gateway that combines multiple existing schemas, we might want to modify one of the schemas. The most common tasks include renaming some of the types, and filtering the root fields. By using [transforms](/docs/schema-transforms) with schema stitching, we can easily tweak the subschemas before merging them together. (In earlier versions of graphql-tools, this required an additional round of delegation prior to merging, but transforms can now be specifying directly when merging using the new subschema configuration objects.)

For example, suppose we transform the `chirpSchema` by removing the `chirpsByAuthorId` field and add a `Chirp_` prefix to all types and field names, in order to make it very clear which types and fields came from `chirpSchema`:

Expand Down Expand Up @@ -509,9 +509,12 @@ The `merge` property on the `SubschemaConfig` object determines how types are me
```ts
export interface MergedTypeConfig {
selectionSet?: string;
resolve?: MergedTypeResolver;
fieldName?: string;
args?: (originalResult: any) => Record<string, any>;
resolve?: MergedTypeResolver;
key?: (originalResult: any) => K;
mapKeysFn?: (keys: ReadonlyArray<K>) => Record<string, any>;
mapResultsFn?: (results: any, keys: ReadonlyArray<K>) => Array<V>;
}

export type MergedTypeResolver = (
Expand All @@ -527,7 +530,9 @@ Type merging simply merges types with the same name, but is smart enough to appl

All merged types returned by any subschema will delegate as necessary to subschemas also implementing the type, using the provided `resolve` function of type `MergedTypeResolver`.

The simplified magic above happens because if left unspecified, we provide a default type-merging resolver for you, which uses the other `MergedTypeConfig` options, as follows:
You can also use batch delegation instead of simple delegation by delegating to a root field returning a list and using the `key`, `mapKeysFn`, and `mapResultsFn` properties. See the [batch delegation](#batch-delegation) for more details.

The simplified magic above happens because if left unspecified, we provide a default type-merging resolver for you, which uses the other `MergedTypeConfig` options (for simple delegation), as follows:

```js
mergedTypeConfig.resolve = (originalResult, context, info, schemaOrSubschemaConfig, selectionSet) =>
Expand Down
6 changes: 4 additions & 2 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ module.exports = {
organizationName: 'ardatan', // Usually your GitHub org/user name.
projectName: 'graphql-tools', // Usually your repo name.
themeConfig: {
defaultDarkMode: true,
colorMode: {
defaultMode: "dark",
},
navbar: {
// title: 'GraphQL Tools',
logo: {
alt: 'GraphQL Tools Logo',
src: 'img/logo.png',
},
links: [
items: [
{
to: 'docs/introduction',
activeBasePath: 'docs',
Expand Down

0 comments on commit ffb642b

Please sign in to comment.