apollographql / apollographql/eslint-plugin-graphql

How would you import directives/etc from AWS AppSync while using basic .graphql schema

Open
#263 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.2k
Forks
93
PR merge metrics
No merged PRs in 30d

Description

Using AWS AppSync you can export both a `.graphql` schema, and a full `.json` schema.

The `.graphql` is your basic actual definitions:

```graphql
schema {
query: AAAAAAAAAAA
}

type AAAAAAAAAAA {
BBBBBBBB(CCCCCCCC: String): String
}
```

Whereas the `.json` includes all of the AWS specifics, as well as the basics from my `.graphql` schema:

- see
[schema.json.txt](https://github.com/apollographql/eslint-plugin-graphql/files/4447343/schema.json.txt)

Ideally I would like to be able to use the main `.graphql` file for simplicity, and include the AWS AppSync specifics from another external file (so that I don't get 'undefined directive' errors and similar)

When I just use the `.graphql` schema I end up with errors such as:

```
Error: Error while loading rule 'graphql/template-strings': Directive aws_subscribe: Couldn't find type aws_subscribe in any of the schemas.
Occurred while linting /Users/devalias/dev/REDACTED/schema.graphql
at collectDirective (/Users/devalias/dev/REDACTED/node_modules/graphql-import/dist/definition.js:113:23)
at Array.forEach ()
at collectNode (/Users/devalias/dev/REDACTED/node_modules/graphql-import/dist/definition.js:105:25)
at /Users/devalias/dev/REDACTED/node_modules/graphql-import/dist/definition.js:87:13
at Array.forEach ()
at collectNewTypeDefinitions (/Users/devalias/dev/REDACTED/node_modules/graphql-import/dist/definition.js:86:30)
at Object.completeDefinitionPool (/Users/devalias/dev/REDACTED/node_modules/graphql-import/dist/definition.js:23:41)
at Object.importSchema (/Users/devalias/dev/REDACTED/node_modules/graphql-import/dist/index.js:99:67)
at Object.readSchema (/Users/devalias/dev/REDACTED/node_modules/graphql-config/lib/utils.js:137:51)
at GraphQLProjectConfig.getSchema (/Users/devalias/dev/REDACTED/node_modules/graphql-config/lib/GraphQLProjectConfig.js:75:28)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```

Not sure of a good source for the full AWS AppSync specifics.. but when googling for things these pages sounded interesting:

- https://www.apollographql.com/docs/graphql-tools/schema-directives/
- https://www.apollographql.com/docs/graphql-tools/schema-transforms/
- https://www.apollographql.com/docs/graphql-tools/remote-schemas/
- https://www.apollographql.com/docs/graphql-tools/schema-stitching/

Contributor guide

Open the contributing guide

Research direction

Start by reading the graphql-import and graphql-config entry points named in the error, then compare the provided schema.graphql with the linked schema.json export. Determine whether the plugin can load AppSync directives from an external schema source; completion would require a documented or implemented path that avoids the reported undefined-directive errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.