Skip to content

Commit

Permalink
[deploy_website] integrated guild-docs as website (#3085)
Browse files Browse the repository at this point in the history
API routes generation fix

docs & components update; routing fixes

gitignore update

fix(deps): update dependency extract-files to v11 (#3065)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

fix(deps): update dependency tslib to ~2.3.0 (#3067)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

fix(deps): update dependency the-guild-components to v1.3.1 (#3070)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

fix(deps): update dependency apollo-upload-client to v16 (#3066)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update typescript-eslint monorepo to v4.27.0 (#3071)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update babel monorepo to v7.14.6 (#3072)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

[deploy_website] Update generate-schema.md (#3074)

corrected grammar

fix(deps): update dependency globby to v11.0.4 (#3077)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

fix(deps): update dependency ws to v7.5.0 (#3078)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency typescript to v4.3.3 (#3083)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency typedoc to v0.20.37 (#3082)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

Jest Transformer for GraphQL (#1887)

* Jest Transformer for GraphQL

* Changeset

* Align versions

* Fix package.json

* yarn.lock

* Fix

Co-authored-by: Arda TANRIKULU <ardatanrikulu@gmail.com>

chore(deps): update dependency @types/ws to v7.4.5 (#3084)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

Safer use of `Object.prototype.hasOwnProperty` (#3069)

* Safer use of `Object.prototype.hasOwnProperty`

Fixes an error I get when GraphQL JS passes a prototypeless object into the resolver

```
ReferenceError: maybeRef is not defined
    at eval (eval at <anonymous> (/Users/mattalexander/Projects/edge-sites-schema/tests/regression.test.js:67:7), <anonymous>:1:38)
    at forEach (/projectpath/tests/regression.test.js:67:7)
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/projectpath/tests/regression.test.js:65:17)
```

* changeset and test

Co-authored-by: Arda TANRIKULU <ardatanrikulu@gmail.com>

BugFix: Handle parsing endpoints when there are no mutations (#3076)

* BugFix: Handle parsing endpoints when there are no mutations

* changeset and test

* pass tests

Co-authored-by: itai <itaimain@gmail.com>
Co-authored-by: Arda TANRIKULU <ardatanrikulu@gmail.com>

chore(deps): update dependency typescript to v4.3.4 (#3086)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency typedoc to v0.21.0 (#3087)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency typedoc-plugin-markdown to v3.10.0 (#3088)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency eslint to v7.29.0 (#3089)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency graphql to v15.5.1 (#3091)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

enable typescript strict mode (#3010)

* enable noImplicitThis

* enable `strictBindCallApply`

* enable `strictFunctionTypes` 1: testing

* enable `strictFunctionTypes` 2: utils

* enable strictFunctionTypes 3: schema

* enable strictFunctionTypes 4: batch-execute

* enable strictFunctionTypes 5 `load`

* enable strictFunctionTypes 6 `loaders/url`

* enable strictFunctionTypes 7 `webpack-loader`

* enable strictFunctionTypes 8 `links`

* enable strictFunctionTypes 9 `delegate` and `batch-delegate`

* enable `strictFunctionTypes` 10 `wrap`

* enable `strictFunctionTypes` 11 `stitch` and `stitching-directive`

* enable `strictFunctionTypes` final tsconfig

* remove unnecessary generic params

* enable `strictNullChecks` 1 `utils`

* enable `strictNullChecks` 2 `schema`

* enable `strictNullChecks` 3 `resolvers-composition`

* enable `strictNullChecks` 4 `webpack-loader`

* enable `strictNullChecks` 5 `batch-execute`

* enable `strictNullChecks` 6 `graphql-tag-plug`

* enable `strictNullChecks` 7 `import`

* enable `strictNullChecks` 8 `loaders/url`

* enable `strictNullChecks` 8 `loaders/prisma`

* enable `strictNullChecks` 8 `loaders/module`

* enable `strictNullChecks` 9 `loaders/github`

* enable `strictNullChecks` 12 `loaders/code-file`

* enable `strictNullChecks` 13 `load`

* enable `strictNullChecks` 14 `delegate`

* enable `strictNullChecks` 15 `batch-delegate`

* interlude: move commonly used stuff to testing folder

* enable `strictNullChecks` 16 `wrap`

* enable `strictNullChecks` 17 `stitch`

* enable `strictNullChecks` 18 `load-files`

* enable `strictNullChecks` 19 `load-typedefs`

* enable `strictNullChecks` 20 `merge`

* enable `strictNullChecks` 21 `node-require`

* enable `strictNullChecks` 22 `mock`

* enable `strictNullChecks` 22 `stitching-directive`

* enable `strictNullChecks` flag in tsconfig

* fix: graphql-js 14 compat

* fix `strictPropertyInitialization` errors

* enable strictPropertyInitialization rule

* strict mode!!!

* enable `noPropertyAccessFromIndexSignature`

* enable `noFallthroughCasesInSwitch` and `noPropertyAccessFromIndexSignature`

* Add strict to new changes

* fix: remove casts as upstream issue is fixed

* fix: throw if we cannot identify the operation type.

#3010 (comment)
#3010 (comment)

* fix: change wording of error

#3010 (comment)

* fix: make error message more clear

#3010 (comment)

* refactor: use null/undefined instead of falsey check

* fix: assert operation from document

#3010 (comment)

* fix: type narrowing not working due to generics

#3010 (comment)

* fix: apply feedback for relocateError

* Make wrapSchema generic. Fix #3064 (#1)

* Fix Build

Co-authored-by: Arda TANRIKULU <ardatanrikulu@gmail.com>
Co-authored-by: Augustin Le Fèvre <augustin.public@gmail.com>

Huge cleanup before major release (breaking) (#3081)

* Breaking cleanup before major release

* Fix TS

* More

chore(deps): update typescript-eslint monorepo to v4.28.0 (#3093)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

fix(deps): update babel monorepo to v7.14.7 (#3094)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update jest monorepo to v27.0.5 (#3095)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency @vue/compiler-sfc to v3.1.2 (#3097)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

fix build errors

Huge cleanup before major release (breaking) (#3081)

* Breaking cleanup before major release

* Fix TS

* More

chore(deps): update typescript-eslint monorepo to v4.28.0 (#3093)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

fix(deps): update babel monorepo to v7.14.7 (#3094)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update jest monorepo to v27.0.5 (#3095)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency @vue/compiler-sfc to v3.1.2 (#3097)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

fix(deps): update dependency the-guild-components to v1.4.0 (#3098)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency @types/node to v14.17.4 (#3101)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

Some other refactor (#3096)

* Fix typing errors in tests

* ReplaObject.keys/values and forEach with for..in and for..of loops

* Improve Type Checking

* Update CI workflow

* Fix linting

* Fix TS errors for v14

* More

* More

* Allow incremental builds

* Finish

* Fix Type Check

* Disable sourcemaps

* Fix type issues

Better changelog

Respect  and  in  and more changes

chore(CI): Ability to release canaries on demand

Make AggregateError spec compliant

reintegration

docs update

updated tgc version and removed Poppins import

Able to release with custom tags

chore(deps): update dependency typedoc-plugin-markdown to v3.10.2 (#3107)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

Prevent TS Server to die on VSCode

chore(deps): update dependency typedoc to v0.21.1 (#3108)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency graphql-tag to v2.12.5 (#3109)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency prettier to v2.3.2 (#3110)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency typedoc to v0.21.2 (#3111)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency @types/babel__traverse to v7.14.0 (#3112)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update jest monorepo to v27.0.6 (#3115)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

Remove Subscriber and use only Executor (#3117)

* Remove Subscriber and use only Executor

* Fix introspectSchema

* Fix tests

* Cleanup

fix(deps): update dependency ws to v7.5.1 (#3118)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

enhance(url-loader): refactor

Fix rawSDL issue

enhance(delegate): skip validation by default and add validateRequest option to enable

chore(deps): update dependency typescript to v4.3.5 (#3122)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

fix(file-loader): location path must be normalized (#3121)

chore(deps): update dependency husky to v7 (#3123)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

feat(graphql-tag-pluck): keep locationOffset and return graphql-js Source instead of string

chore(deps): update dependency @vue/compiler-sfc to v3.1.3 (#3125)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency @vue/compiler-sfc to v3.1.4 (#3126)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

fix(deps): update dependency @types/websocket to v1.0.3 (#3129)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency @types/ws to v7.4.6 (#3128)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency eslint to v7.30.0 (#3130)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

fix(deps): update dependency ws to v7.5.2 (#3131)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

fix(url-loader): fix node support for EventSource

feat(resolvers-composition): add support for glob patterns (#3132)

* feat(resolvers-composition): add support for glob patterns

* fix(resolvers-composition): add typings for micromatch

* feat(resolvers-composition): add unit tests for glob patterns

* chore(resolver-compositions): cleanup

* feat(docs): added samples for resolver composition path matcher format

* chore: added changeset

* fix(docs): typo

* fix(changeset): change patch to minor

* Fix tests and cleanup

Co-authored-by: Arda TANRIKULU <ardatanrikulu@gmail.com>

chore(deps): pin dependency @types/micromatch to 4.0.1 (#3133)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

chore(deps): update dependency nock to v13.1.1 (#3134)

Co-authored-by: Renovate Bot <bot@renovateapp.com>

don't throw on errors that should not be relocated (#3136)

refactor: internal StitchingInfo properties (#3137)

to never be undefined

docs update

docs update after review

Some fixes

update tgc version
  • Loading branch information
alinsimoc authored Jul 28, 2021
1 parent c23b5b8 commit cfa0712
Show file tree
Hide file tree
Showing 65 changed files with 3,455 additions and 5,177 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@ junit.xml

package-lock.json
website/yarn.lock
website/api-sidebar.json
website/docs/api
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
},
"resolutions": {
"graphql": "15.5.1",
"esbuild": "^0.12.8",
"@changesets/apply-release-plan": "5.0.0"
}
}
48 changes: 31 additions & 17 deletions scripts/build-api-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async function buildApiDocs() {
const packageJsonContent = require(path.join(__dirname, '..', packageJsonPath));
// Do not include private and large npm package that contains rest
if (
!packageJsonPath.includes('./website/') &&
!packageJsonContent.private &&
packageJsonContent.name !== MONOREPO &&
!packageJsonContent.name.endsWith('/container')
Expand Down Expand Up @@ -80,6 +81,13 @@ async function buildApiDocs() {
// Escape angle brackets
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
// Fix title
.replace(/^# .+/g, function (match) {
return `---
title: '${match.replace('# ', '')}'
---
${match}`;
})
// Fix links
.replace(/\[([^\]]+)\]\(([^)]+).md\)/g, '[$1]($2)')
.replace(/\[([^\]]+)\]\((\.\.\/(classes|interfaces|enums)\/([^\)]+))\)/g, '[$1](/docs/api/$3/$4)');
Expand Down Expand Up @@ -109,8 +117,8 @@ async function buildApiDocs() {
})
);

// Remove the generated "index.md" file
// fs.unlinkSync(path.join(outputDir, 'index.md'));
// Remove the generated "README.md" file
fs.unlinkSync(path.join(outputDir, 'README.md'));

// Update each module 's frontmatter and title
await Promise.all(
Expand Down Expand Up @@ -142,20 +150,27 @@ sidebar_label: "${id}"
fs.writeFileSync(
sidebarsPath,
JSON.stringify(
[
{
Modules: modules.map(([name]) => `api/modules/${convertNameToId(name)}`),
},
{
Classes: getSidebarItemsByDirectory(path.join(outputDir, 'classes')),
},
{
Interfaces: getSidebarItemsByDirectory(path.join(outputDir, 'interfaces')),
},
{
Enums: getSidebarItemsByDirectory(path.join(outputDir, 'enums')),
{
$name: 'API Reference',
_: {
modules: {
$name: 'Modules',
$routes: getSidebarItemsByDirectory(path.join(outputDir, 'modules')),
},
classes: {
$name: 'Classes',
$routes: getSidebarItemsByDirectory(path.join(outputDir, 'classes')),
},
interfaces: {
$name: 'Interfaces',
$routes: getSidebarItemsByDirectory(path.join(outputDir, 'interfaces')),
},
enums: {
$name: 'Enums',
$routes: getSidebarItemsByDirectory(path.join(outputDir, 'enums')),
},
},
],
},
null,
2
)
Expand Down Expand Up @@ -183,8 +198,7 @@ sidebar_label: "${id}"
const absoluteFilePath = path.join(dirName, fileName);
const fileLstat = fs.lstatSync(absoluteFilePath);
if (fileLstat.isFile()) {
const relativeDirName = path.relative(outputDir, dirName);
return `api/${relativeDirName}/${path.parse(fileName).name}`;
return path.parse(fileName).name;
} else {
return getSidebarItemsByDirectory(absoluteFilePath);
}
Expand Down
26 changes: 0 additions & 26 deletions website/.gitignore

This file was deleted.

42 changes: 0 additions & 42 deletions website/README.md

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ This example has the entire type definition in one string and all resolvers in o

## Extending Types

It's easy to add additional fields to existing types using the `extend` keyword. Using `extend` is particularly useful in avoiding a large list of fields on root Queries and Mutations. You can use it like this:
It's easy to add additional fields to existing types using the `extend` keyword. Using `extend` is particularly useful in avoiding a large list of fields on root Queries and Mutations. You can use it like this:

```js
const typeDefs = [`
const typeDefs = [
`
schema {
query: Query
}
Expand All @@ -120,15 +121,17 @@ const typeDefs = [`
type Bar {
id
}
`, `
`,
`
type Foo {
id: String!
}
extend type Query {
foos: [Foo]!
}
`]
`,
];
```

If one of the types extended needs a resolver you can use `makeExecutableSchema` like this:
Expand All @@ -138,39 +141,42 @@ const barsResolver = {
Query: {
bars(parent, args, context, info) {
// ...
}
}
},
},
};

const foosResolver = {
Query: {
foos(parent, args, context, info) {
// ...
}
}
}
},
},
};

const schema = makeExecutableSchema({
typeDefs,
resolvers: [barsResolver, foosResolver]
})
resolvers: [barsResolver, foosResolver],
});
```

## Learning the GraphQL schema language

The official documentation on graphql.org now has [a section about GraphQL schemas](http://graphql.org/learn/schema/) which explains all of the different schema features and how to use them with the schema language.

The type definitions must define a query type, which means a minimal schema would look something like this:

```js
const typeDefs = [`
const typeDefs = [
`
schema {
query: RootQuery
}
type RootQuery {
aNumber: Int
}
`];
`,
];
```

## Descriptions & Deprecations
Expand Down Expand Up @@ -232,16 +238,16 @@ const jsSchema = makeExecutableSchema({
- `parseOptions` is an optional argument which allows customization of parse when specifying `typeDefs` as a string.

- `resolverValidationOptions` is an optional argument with the following properties, each of which can be set to `error`, `warn`, or `ignore`:

- `requireResolversForArgs` will cause `makeExecutableSchema` to throw an error (`error`) or issue a warning (`warn`)unless a resolver is defined for every field with arguments. The default is `ignore`, causing this validator to be skipped.

- `requireResolversForNonScalar` require a resolver for every non-scalar field. Default is `ignore`.

- `requireResolversForAllFields` asserts that *all* fields have valid resolvers. This option cannot be set in combination with the previous two validators. Default is `ignore`.
- `requireResolversForAllFields` asserts that _all_ fields have valid resolvers. This option cannot be set in combination with the previous two validators. Default is `ignore`.

- `requireResolversForResolveType` will require a `resolveType()` method for Interface and Union types. This can be passed in with the field resolvers as `__resolveType()`. Default is `ignore`.

- `requireResolversToMatchSchema` requires every resolver within the resolver map to correspond to a GraphQL entity within the schema. Defaults to `error`, to help catch common errors.

- `inheritResolversFromInterfaces` GraphQL Objects that implement interfaces will inherit missing resolvers from their interface types defined in the `resolvers` object.


File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ The following is an example of a simple logged-in authorization logic:
Instead of doing this,

```js
const resolvers ={
Query: {
myQuery: (root, args, context) => {
// Make sure that the user is authenticated
if (!context.currentUser) {
throw new Error('You are not authenticated!');
}

// Make sure that the user has the correct roles
if (!context.currentUser.roles || context.currentUser.roles.includes('EDITOR')) {
throw new Error('You are not authorized!');
}

// Business logic
if (args.something === '1') {
return true;
}

return false;
},
const resolvers = {
Query: {
myQuery: (root, args, context) => {
// Make sure that the user is authenticated
if (!context.currentUser) {
throw new Error('You are not authenticated!');
}

// Make sure that the user has the correct roles
if (!context.currentUser.roles || context.currentUser.roles.includes('EDITOR')) {
throw new Error('You are not authorized!');
}

// Business logic
if (args.something === '1') {
return true;
}

return false;
},
},
};
```

Expand All @@ -42,36 +42,36 @@ You can do;
```js
const { composeResolvers } = require('@graphql-tools/resolvers-composition');

const resolvers ={
Query: {
myQuery: (root, args, context) => {
if (args.something === '1') {
return true;
}
const resolvers = {
Query: {
myQuery: (root, args, context) => {
if (args.something === '1') {
return true;
}

return false;
},
return false;
},
},
};

const isAuthenticated = () => next => async (root, args, context, info) => {
if (!context.currentUser) {
throw new Error('You are not authenticated!');
}
if (!context.currentUser) {
throw new Error('You are not authenticated!');
}

return next(root, args, context, info);
return next(root, args, context, info);
};

const hasRole = (role: string) => next => async (root, args, context, info) => {
if (!context.currentUser.roles || context.currentUser.roles.includes(role)) {
throw new Error('You are not authorized!');
}
if (!context.currentUser.roles || context.currentUser.roles.includes(role)) {
throw new Error('You are not authorized!');
}

return next(root, args, context, info);
return next(root, args, context, info);
};

const resolversComposition = {
'Query.myQuery': [isAuthenticated(), hasRole('EDITOR')],
'Query.myQuery': [isAuthenticated(), hasRole('EDITOR')],
};

const composedResolvers = composeResolvers(resolvers, resolversComposition);
Expand All @@ -80,12 +80,12 @@ const composedResolvers = composeResolvers(resolvers, resolversComposition);
`composeResolvers` is a method in `@graphql-tools/resolvers-composition` package that accepts `IResolvers` object and mappings for composition functions that would be run before resolver itself.

### Supported path matcher format

The paths for resolvers support `*` wildcard for types and glob patters for fields, eg:

- `*.*` - all types and all fields
- `Query.*` - all queries
- `Query.single` - only a single query
- `Query.{first, second}` - queries for first/second
- `Query.!first` - all queries but first
- `Query.!{first, second}` - all queries but first/second


File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ The resolver function for the `repositories` field of the `User` type would be r

```graphql
# To the subschema
query($id: ID!) {
query ($id: ID!) {
repositoriesByUserId(id: $id) {
id
url
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit cfa0712

Please sign in to comment.