(v1?) Rework usage to be more unified
Adding directives to SDL was mainly inspired by neo4j-graphql-js, but the disconnect between writing raw SDL and then connecting resolvers has lead me to multiple confusing broken behaviors (mainly forgetting resolvers).
Plus, there's some advanced functionality like runQuery which just won't fit in SDL and requires you to move to JS code anyways.
There's no sense in being afraid to write code. I'll try sketching some ideas for a more code-driven experience in this issue.
Concept: JS-based resolver-centric, model-centric configuration
const User = {
sdl: gql`
type User {
id: ID!
name: String!
posts: [Post!]!
}
`,
fields: {
id: aqlId(),
posts: aqlNode({
edgeCollection: 'Posted',
edgeDirection: EdgeDirection.OUT,
}),
}
};
Alternative: pure JS model-centric
const User = {
kind: 'type',
fields: {
id: {
returns: 'ID!',
resolve: aqlId(),
},
name: 'String!',
posts: {
returns: '[Post!]!',
resolve: aqlNode({ ... }),
},
}
};
Questions: how are root fields done? Just on a Query type? Won't that be unruly?
Concept: template-string based, SDL-centric
const schema = aqlgql`
type User {
id: ID!
name: String!
posts: [Post!]! ${userPosts}
}
extend type Query {
user(id: ID!): User ${queryUser}
}
`;
const userPosts = aqlNode({ edgeCollection: 'Posted', edgeDirection: EdgeDirection.OUT });
const queryUser = aqlDocument({ key: '$args.id', collection: 'Users' });
Questions: what's the actual output? Are directives added as interpolations? Is it possible to infer type/field position of resolvers from the SDL they're injected into so arg resolvers can be applied?
@a-type The first one made the most sense to me! It's clean, simple, and feels familiar! But I may be mistaken as I'm a GraphQL beginner myself. But that's my 2-cents!
Thanks again for this amazing project, one of the best ones trying to glue ArangoDB and GraphQL.