Graphql-js: Restructuring of Type Definition API

Created on 19 Aug 2015  路  2Comments  路  Source: graphql/graphql-js

This task seeks to track all feedback on the GraphQL type definition API. Once enough feedback has been collected to project a clear course of action, a new type definition API will be proposed, and implemented in a following major version with clear instructions for moving along existing code.

needs exploration

Most helpful comment

As stated in #130, the way types are exported is problematic:

import {
  GraphQLObjectType,
  GraphQLNonNull,
  GraphQLString,
} from 'graphql';

graphql-js should export a Types object which contains all the types without the "GraphQL" prefix:

import { Types as GqlTypes } from 'graphql';

// GqlTypes.ObjectType
// GqlTypes.NonNull
// GqlTypes.String

We can add the "Types" export without breaking 0.4 and remove prefixed types in 0.5.

All 2 comments

As stated in #130, the way types are exported is problematic:

import {
  GraphQLObjectType,
  GraphQLNonNull,
  GraphQLString,
} from 'graphql';

graphql-js should export a Types object which contains all the types without the "GraphQL" prefix:

import { Types as GqlTypes } from 'graphql';

// GqlTypes.ObjectType
// GqlTypes.NonNull
// GqlTypes.String

We can add the "Types" export without breaking 0.4 and remove prefixed types in 0.5.

I think we stabilize our Type Definition API enough over the last 3 years.
So if someone wants to report any issue with it should be reported separately.

As for having separate Types I think schema definition methods are shifting towards SDL and GraphQL* classes as the internal mechanism and for advanced scenarios.

Was this page helpful?
0 / 5 - 0 ratings