Skip to content
This repository has been archived by the owner on Jul 31, 2022. It is now read-only.

Validation and auto-completion for hand-typed info objects in resolvers #33

Closed
jhalborg opened this issue Jun 20, 2018 · 1 comment
Closed
Labels
enhancement New feature or request

Comments

@jhalborg
Copy link

As discussed in this forum post

I'm wondering if there is any way to validate handwritten queries passed instead of info in Prisma resolvers against the Prisma DB schema? In the following example, I have a User model that has a reference to a UserCredentials model. In the login resolver, I will find the UserCredential by the passed email, and find the relevant User's ID from a handwritten query:

resolve: async (parent, { email, password }, ctx, info) => {
    const userCredentials = await ctx.db.query.userCredential({ where: { email } }, `{id password user {id}}`);
    ...
}

I would like to check queries like that against the schema - how would I do that? 😃

And even better - how could you get auto completion in VSCode for these strings?

PS: The idea came from the HowToGraphQL tutorial project (https://github.com/howtographql/graphql-js/blob/master/src/resolvers/Mutation.js#L34)

@marktani marktani changed the title [Feature] Validation and auto-completion for hand-typed info objects in resolvers Validation and auto-completion for hand-typed info objects in resolvers Jun 20, 2018
@marktani marktani added the enhancement New feature or request label Jun 20, 2018
@jhalborg
Copy link
Author

jhalborg commented Jul 2, 2018

Just as there's an option to inspect the DB from a playground as it runs on a different port than the app, would it be possible to have another key in the graphqlconfig.yml that listens to that port and validates gql tags or .graphql files against that, perhaps alongside a regular .graphql app instance? Say, something like this:

{
  "projects": {
    "app": {
      "schemaPath": "schema.graphql",
      "includes": ["**/*.{graphql,ts,tsx}"],
      "extensions": {
        "endpoints": {
          "dev": "http://localhost:4000/graphql"
        }
      }
    },
    "db": {
      "schemaPath": "schema.graphql",
      "includes": ["**/*.{graphql,ts,tsx}"],
      "extensions": {
        "endpoints": {
          "dev": "http://localhost:4001/db"
        }
      }
    }
  }
}

@acao acao closed this as completed Apr 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants