matthewmueller / matthewmueller/graph.ql

Interface implementations missing from schema with graphql-js 0.5.0

Open
#22 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
629
Forks
27
PR merge metrics
No merged PRs in 30d

Description

Hey.

First of all, thanks for this awesome library.

There's a breaking change in graphql-js v.0.5.0 that reads as follows:

  • Types which implement an interface but are otherwise not referenced as a field return type are no longer automatically added to the Schema

It appears that it's now possible to pass types to include explicitly in the constructor of graphql.GraphQLSchema in index.js:

function Create (schema, implementation) {

  // ....

  // create an array of all types
  var all_types = Object.keys(object_types).map(function(typeName) {
    return object_types[typeName];
  });

  var schema = new graphql.GraphQLSchema({
    query: object_types['Query'],
    mutation: object_types['Mutation'],
    subscription: object_types['Subscription'],
    // and pass them here to include them in v.0.5.0 of graphql-js
    types: all_types
  });

  // .....
}

Adding all_types to the schema fixed our use case. I'm not sure whether this should be the default behaviour though.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/index.js at Create and inspect how object_types are collected before graphql.GraphQLSchema is constructed. Check the graphql-js 0.5.0 schema behavior for interface implementations that are not field return types, then verify that the affected implementations are included in the resulting schema without breaking the existing query, mutation, or subscription setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, javascript
Domain
api, backend-api-design
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.