Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

0.16.0

Compare
Choose a tag to compare
@craicoverflow craicoverflow released this 01 Sep 10:48
· 282 commits to master since this release
97ac02a

New Features

  • Use any knex 0.20.x or 0.21.x version in your application (d826b6f#1903)

  • Ability to specify composite unique columns in GraphQL Migrations (#1658), fixed by (9c6f34a231e2645c34533d58ea4427ff8f8f634e)

  • Requiring _id: GraphbackObjectID primary key for MongoDB (#1769).
    This fixes issues below related to primary key in MongoDB:

    • #1731, #1626 Ineffecient and wrong mapping of the id field
    • #1625 Filters on "id: ID" field not working

    NOTE: If you are migrating from 0.15 or previous versions of Graphback, you may be required to update relationship fields so that their values (previous stored as String) are of type ObjectID.

  • Add a @transient field annotation to ignore fields during input type creation and migrations 4076fa26

DataSync

  • Using a _lastUpdatedAt field with a proper GraphbackTimestamp scalar and other minor fixes (#1771) including:

    • disabling conflicts in default configuration
    • adding a limit argument to sync Queries

Bug Fixes

Breaking Changes

  • Use GraphbackDateTime scalar for generated createdAt updatedAt fields (#1349, fixed by #1862)

Disable filter input generation for unknown custom scalars

Graphback disabled generation of unknown custom scalars, except for Timestamp, Time, Date, DateTime, as we cannot reliably support scalars we do not know.

See Graphback Scalars for the list of officially supported scalars.

  • Replace @db(skip: true) field annotation with @transient 85d50f3c

Changed GraphbackCRUDService findBy method signature. This also applies to all services that implement this interface.

- findBy(filter: QueryFilter<Type>, context: GraphbackContext, page?: GraphbackPage, orderBy?: any): Promise<ResultList<Type>>;
+ findBy(args?: FindByArgs, context?: GraphbackContext, info?: GraphQLResolveInfo, path?: string): Promise<ResultList<Type>>;

args

findBy now accepts a new interface, FindByArgs, which wraps the filter, page and orderBy optional arguments.

await noteService.findBy({
  filter: {
    id: {
      gt: 100
    }
  },
  page: {
    offset: 0,
    limit: 10
  },
  orderBy: {
    field: 'id'
  }
})

context (optional)

The context parameter is now optional.

info

You can now optionally pass the GraphQLResolveInfo info object to the CRUD service, to perform extra optimizations like retrieving only the selected fields from the query.

await noteService.findBy(filter, context, info);

path (optional)

The root path of the query to get the selected fields from. For example, to get id, title, description fields from the following query, you would set the path to items.

query findNotes {
  findNotes {
    items {
      id
      title
      description
    }
  }
} 

The path variable is optional, as it will automatically resolve to the root field of the entire query.

context parameter removed from subscribeToCreate, subscribeToDelete, subscribeToUpdate methods in GraphbackCRUDService.

This method was unused.

Removed context parameter from all GraphbackDataProvider methods. This also applies to all providers that implement this interface.

All CRUD methods in GraphbackDataProvider had a context parameter used to get the selected fields.
These have been replaced with (optional) selectedFields - you can pass a string array of the fields you want to select from the database.

await noteProvider.findBy(filter, ['id', 'name']);

Changed GraphbackDataProvider findBy method signature. This also applies to all providers that implement this interface.

args

findBy now accepts a new interface, FindByArgs, which wraps the filter, page and orderBy optional arguments.

await noteService.findBy({
  filter: {
    id: {
      gt: 100
    }
  },
  page: {
    offset: 0,
    limit: 10
  },
  orderBy: {
    field: 'id'
  }
})

Remove resolver options from GraphbackContext

Resolver options (context.graphback.options) was removed from the context because the count aggregation and selectedFields extraction logic was moved to the CRUDService method.

Removed graphback key from GraphbackContext

The graphback.services property has been removed from GraphbackContext, and graphback is now the service map property.

export interface GraphbackContext {
-  graphback: {
-    graphback: GraphbackServiceConfigMap
-  }
+  graphback: GraphbackServiceConfigMap
}

Now you can reach the Graphback service map by calling context.graphback.Note.findBy(...).

CRUDService, DataSyncCRUDService now accepts a ModelDefinition as the first constructor parameter.

To instantiate a CRUDService you must pass the full ModelDefinition instead of the model name.

const myService = new CRUDService(modelDefinition, ...);

KeycloakCrudService now accepts a ModelDefinition as the first constructor parameter.

To instantiate a CRUDService you must pass the full ModelDefinition instead of the model name.

const myService = new KeycloakCrudService(modelDefinition, ...);

DataSyncProvider sync method signature has been changed

- sync(lastSync: Date, context: GraphbackContext, filter?: any, limit?: number): Promise<Type[]>;
+ sync(lastSync: Date, selectedFields?: string[], filter?: QueryFilter, limit?: number): Promise<Type[]>;

The context argument has been replaced with (optional) selectedFields.

context parameter is removed from the create method in MongoDBDataProvider and DatasyncMongoDBDataProvider providers.

This parameter did not do anything.