I have seen people having linting on the client si...
# orm-help
n
I have seen people having linting on the client side like in a .gql file Is this possible with prisma? How does the frontend know what the schema looks like in the backend. The guy I saw doing this had the data in a mock.json I think this has to do with graphql codegen, if could generate a .ts file or .graphql then you should be able to generate .json aswell. I'm also noticing that there is an option when you run graphql-cli
graphql
That you should be able to output the schema as JSON file Anyone out there that have done something like this with prisma please share this workflow. Is there such thing as graphql-linting?
d
If you are using VSCode then this might help 🙂 https://github.com/prisma/vscode-graphql Please note that finding the correct schema for a gql tag is currently implemented in a guess fashion, might be a bit buggy. We can talk more about this subject otherwise, feel free to DM me.
n
I'm actually using this plugin I had problem before when it came to installing on my windows machine but that's solved now. It´s working now But I having hard time to understanding how the client knows the schema Let say I have
create-react-app
I starting to write my gql tags. Will the linting automatically work here? It shouldn't I feel maybe they are some pre steps that you got do to make linting work. Do you have any example of a project where this plugin work as linting for gql. I'm actually reading the
readme.md
for this plugin it does not mention how the client know what schema the backend has. It would be helpful if you had fullstack-project displaying how the plugin works in that enviroment
d
The includes part of
.graphqlconfig
is where the linking happens - https://github.com/prisma/vscode-graphql#usage
n
I didn't notice much linting(red scribbling lines) with this plugin however I can execute a query. You said that implemented in a guess fashion. Any way to make it more accurate
d
One approach that we are thinking of it to tag the schema name with
gql
tag like
gql.schema1
. More details here: https://github.com/Microsoft/typescript-template-language-service-decorator/issues/8 Another idea is to make it deterministic via graphql config But we are open to more ideas!
n
@divyendu If I want to have those red scribbling lines ... how do I achieve it? I have seen it being done so it has to be possible in a way and I'm guessing some in graphql community uses linting. I wonder how this one work https://github.com/apollographql/eslint-plugin-graphql It seems to expect a schema.json
d
Thanks!