Hi Jim,
I am getting a warning while try to use fragment in a query (which executes without any error):

fragment basicInfo on Bathroom {
name
slug
}
query {
bathrooms (pager: {
limit: 1,
type: NUMBER
}) {
nodes {
...basicInfo
}
}
}
But no error return after fetch data:
{
"data": {
"bathrooms": {
"nodes": [
{
"name": "1",
"slug": "1"
}
]
}
}
}
Details:
PhpStorm 2019.1 EAP
Build #PS-191.6014.13, built on March 6, 2019
PhpStorm EAP User
Expiration date: April 5, 2019
JRE: 1.8.0_202-release-1483-b31 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 8.1 6.3
---
JS GraphQL: v2.0.0-alpha-8
P.S. Please let me know if you need more details.
Thanks!
Hi Junaid.
Can you confirm that you're only seeing this issue in scratch files, and not with files picked up as part of the regular project source files?
Yes Jim, Only in a scratch file.
Now facing another issue here:
.graphqlconfig File (No errors)

The Files structure:

The schema file is placed with it:

Now if I remove "node/graphql/schema/**/*.graphql" from exclude:
"excludes": [
"node/graphql/schema/**/*.graphql"
],
to
"excludes": [
],
I get a load of following warnings:

Error: The input value type 'QueryFilterEnum' is not present when resolving type 'FilterQueryInput' [@3:1]
File inputs.graphql
input FilterQueryInput {
query: String!
column: String
rule: QueryFilterEnum
}

Error: 'Query' type [@46:1] tried to redefine existing 'Query' type [@40:1]
File me.graphql
type Query {
me: Me! @auth @cost(complexity: {min: 2})
myLoginHistory: MyloginHistory! @auth @cost(complexity: {min: 2})
}

Maybe due to split schema into multiple files?
I am using graphql-import
I figured it out.
The reason is: both schema-graphql.json and *.graphql files are present at the same time.
Both contain identical contents, so that's why!
Fragment definitions will be picked up in scratch files as well for the upcoming beta-1 release.
Best regards,
Jim.
Thank you, Jim, for your great efforts!
Hello everyone,
I have an issue that prints a similar message.
Versions:
2019.2.14.7Use case:
A bunch of .graphql files (each defining type Query and type Mutation) that I merge with mergeSchemas.
The GraphQL tab in the IDE, under "Schema errors", shows errors such as:
'Query' type [@8:1] tried to redefine existing 'Query' type [@1:1]'Mutation' type [@15:1] tried to redefine existing 'Mutation' type [@88:1]Here's my .graphqlconfig:
{
"name": "GraphQL Schema",
"includes": [
"*.graphql"
],
"extensions": {
"endpoints": {
"GraphQL Endpoint": {
"url": "http://localhost:8080/graphql",
"headers": {
"user-agent": "JS GraphQL"
},
"introspect": false
}
}
}
}
Any way to fix this? Thanks!
@dandrei By merging you're essentially redeclaring the Query and Mutation types in your project.
You need to configure schema discovery such that the two logical schemas don't "step on each others toes". You can do this by placing the generated schema in a separate folder with its own .graphqlconfig, and then excluding it from your current .graphqlconfig using the excludesarray.
More info on schema discovery is available at https://jimkyndemeyer.github.io/js-graphql-intellij-plugin/docs/developer-guide#project-structure-and-schema-discovery
@dandrei Yeah that's the valid issue. When you split your schema into multiple files. This error always popup.
@jimkyndemeyer I am facing the same issue. Do you plan to fix this issue?
P.S. I am using the following library to split my schema into chunks (later combined on runtime):
https://github.com/prisma/graphql-import
@blacksmoke26 To your question "Do you plan to fix this issue?". I'm not sure what kind of "fix" you are expecting here? There's countless ways to implement a GraphQL endpoint, and this plugin supports two spec-compliant ways of discovering your schema: introspection and GraphQL SDL controlled by graphql-config includes/excludes.
To my knowledge this allows you to split up your GraphQL files however you want, and combine them with your choice of runtime, given that you use graphql-config to produce valid schemas/type registries such that types are not redefined.
Thanks, @jimkyndemeyer for your reply.
I am excepting at least disable the warning or Inspection?

Inspections > Graphql > [x] Warn about duplicate types declaration.
@blacksmoke26 It's more complicated than a simple inspection. A lot of the features in the plugin depend on types being uniquely defined within the scope of a schema. Without that assumption features such as go to definition, completion, error highlighting, and find usages don't work or make sense. All these features require that your type is defined once in a source code scope, and that a valid type registry can be built for validation and completion.
Similar restrictions and assumptions underly the language tooling for other typed languages on the IntelliJ platform, so it's not unique to this plugin.
From what I know of graphql-config and the use of includes/excludes you should be able to properly scope your "authoring/split" schema graphql files and the resulting "merged" schema such that they are separate scopes and valid.
@jimkyndemeyer the issue is that graphql-import allows me to do this:
# src/graphql/users/schema.graphql
type User {
id: ID!
name: String!
}
type Query {
users: [User!]!
user(id: ID!): User!
}
# src/graphql/messages/schema.graphql
type Message {
id: ID!
from: User!
to: User!
date: String!
text: String!
}
type Query {
messages: [Message!]!
messagesFrom(userId: ID!): [Message!]!
messagesTo(userId: ID!): [Message!]!
}
type Mutation {
sendMessage(to: ID!, text: String!): Message
}
Basically it allows me to not only split the definitions of the types into separate files kept alongside the appropriate resolvers and other code related to a specific group of endpoints, it also allows me to keep the definitions of the _operations_ for any given group of endpoints alongside the types. This does wonders for code organisation and refactoring. I know I could still keep the User and Message type definitions in separate files, but then I'd need to have separate src/graphql/query.graphql and src/graphql/mutation.graphql files which would be just huge and all-round awful to work with.
@jahudka Have you tried the following:
# operations.graphql
type Query
type Mutation
# other-schema-files.graphql
extend type Query {
operationName: OperationType
}
extend type Mutation {
operationName: OperationType
}
This validates according to the GraphQL spec, and should be supported by the plugin.
The same extends approach is used by Apollo to add client fields to the Query type and other types: https://github.com/jimkyndemeyer/graphql-config-examples/blob/master/extend-client-fields-and-directives/client-schema-extensions.js
@jimkyndemeyer unfortunately, I have tried it: https://github.com/Urigo/graphql-import/issues/42
Im getting this same error when using simple .graphql files with nestJS which support splitting.
users.graphql
