src/graphql/Schema.tssrc/graphql/Mutation.tssrc/graphql/User.ts (GraphQLObjectType)src/graphql/mutations/UserMutation.ts
Put edges in a "Viewer" GraphQLObjectType so that you can use it as the "root" object.
type Query {entries(order: String, sort: String, after: String, first: Int, before: String, last: Int): EntryConnectiontags(after: String, first: Int, before: String, last: Int): TagConnectionviewer: Viewer}​type Viewer implements EntryConnectionInterface {entries(order: String, sort: String, after: String, first: Int, before: String, last: Int): EntryConnectiontags(after: String, first: Int, before: String, last: Int): TagConnection}
Naming:
Postfix function names with Resolver
Pass in all the args: root, args, context, info
Entry.ts// For the connections`query {entries(...) {edges...}}`export async function EntriesResolver(root, args, context, info);​`query {entry(...) { }}`export async function EntryResolver(root, args, context, info);​// My suggestion is put this function in the `Tag.ts` file.// The goal is put all Resolvers that query the same database in the same file`query {entry(...) {tags(...) {edges...}}}`export async function EntryTagsResolver(root, args, context, info) {const row = await knex.from("tags").where({tag.entryID: root.id,}).select();...}
export async function EntryResolver(root,args,context: Context,info): Promise<any> {const userUUID = getUserUUIDFromContext(context);​const where = {uuid: args.uuid,createdBy: userUUID};​const row = await knex.from("users").where(where).limit(1).select();return row.shift();}
When running relay-compiler
I would get this error:
Could not convert from GraphQL type String
Environment: Lerna with multiple graphql
packages installed
Solution specify resolutions
in local package.json
:
package.json"resolutions": {"graphql": $your_version}
Worse case, nuke your node_modules
:
rm -rf \packages/your-package/node_modules/ \node_modules/ \yarn.lock