cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

orderBy with makeAugmentedSchema

We have recently moved from using augmentSchema to makeAugmentedSchema to provide us with our graphQL schema via the neo4j-graphql-js library.

During this move we lost our orderBy fields. We now only have _id_asc and _id_desc as recognized criteria of our _XxxxxxxOrdering definitions.

Are you aware of this issue or is it something we did when upgrading our use of the libraries? Our code is as follows:

const makeGraphqlSchema = makeExecutableSchema({
	typeDefs: getGraphqlDefs(),
	resolvers: resolvers.all,
	logger: {
		log(message) {
			logger.error(`GraphQL Schema: ${message}`, {
				event: 'GRAPHQL_SCHEMA_ERROR',
			});
		},
	},
});
const config = { query: true, mutation: false };
const schema = makeAugmentedSchema({ schema: makeGraphqlSchema, config });

We are currently running v4.0.3 or graphql-tools and v2.3.1 of neo4j-graphql-js.

Thanks
Geoff

4 REPLIES 4

William_Lyon
Graph Fellow

It could be that since resolvers and an already constructed schema object are provided, the schema augmentation process is having some issues constructing the ordering enums (although I'm not sure why exactly).

makeAugmentedSchema wraps makeExecutableSchema from graphql-tools so you shouldn't need the call to makeExecutableSchema. Could you try:

const schema = makeAugmentedSchema({
  typeDefs: getGraphqlDefs(),
  resolvers: resolvers.all,
  logger: ...
  config: {query: true, mutation: false}
})

We intended makeAugmentedSchema to work with typedefs and augmentSchema to work with an already constructed GraphQLSchema object, which is a bit more difficult for the schema augmentation bit. Maybe @michaeldgraham can chime in with some more insight.

(Also, since I believe your resolvers are essentially just binding the neo4jgraphql function to each Query field, I don't think those are necessary either).

William, Thanks for the swift response and code suggestion, Unfortunately I now get a "TypeError: Must provide Source. Received: [object]" error which lists all my typedefs.

William_Lyon
Graph Fellow

@geoff.thorpe I was able to reproduce your error.

Looks like we don't yet support passing an array of type definitions to makeAugmentedSchema (which is supported by makeExecutableSchema in graphql-tools). I've created an issue to track fixing that properly, but in the meantime, a workaround could be to construct a single string from your array of type definition strings:

const schema = makeAugmentedSchema({
	typeDefs: getGraphqlDefs().join('\n'),
	resolvers: resolvers.all,
	 logger: {
	 	log(message) {
	 		logger.error(`GraphQL Schema: ${message}`, {
	 			event: 'GRAPHQL_SCHEMA_ERROR',
	 		});
		},
	 },
	config: {query: true, mutation: false}
});

Many thanks William that fix works a treat.

However, there is a related quirk with orderBy on nested fields. Is that supported with this version. I cant see the orderBy option in graphiql for my nested fields.