### Example .env File Content Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This snippet illustrates the typical content of a `.env` file, showing key-value pairs for environment variables. Values can be optionally enclosed in quotes, and comments are supported using the hash symbol. ```dotenv S3_BUCKET="YOURS3BUCKET" SECRET_KEY=YOURSECRETKEYGOESHERE # comment SECRET_HASH="something-with-a-#-hash" ``` -------------------------------- ### Example Project Directory Structure for Multi-Project GraphQL Configuration Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md Illustrates the recommended directory layout for a GraphQL project that uses a single configuration file to manage multiple schemas (e.g., 'frontend' and 'backend') and a shared 'queries' directory. ```text - project root/ - .graphql.config.yml <----- - frontend (schema one)/ - schema files and graphql aware components - backend (schema two)/ - schema files and graphql aware components - queries/ ``` -------------------------------- ### Basic JavaScript GraphQL Configuration File Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md Provides an example of a `graphql.config.js` file using Node.js `module.exports` syntax to specify a GraphQL schema endpoint. This configuration type requires Node.js and the JavaScript plugin to be installed in the IDE and is supported in IntelliJ IDEA Ultimate and other full editions. ```javascript module.exports = { schema: 'https://localhost:8000' } ``` -------------------------------- ### Modern GraphQL Config with Endpoints Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This YAML configuration demonstrates a modern GraphQL setup using the `extensions` key to define API endpoints. An empty configuration file containing only this key will implicitly include all GraphQL files in its directory. ```yaml extensions: endpoints: dev: https://example.com/graphql ``` -------------------------------- ### Basic GraphQL Configuration with `graphql.config.yml` Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This configuration demonstrates a simple `graphql.config.yml` setup. It specifies a local `schema.graphql` file for type definitions and uses a glob pattern (`**/*.graphql`) to include all GraphQL operations (queries, fragments) in the project, ensuring paths are relative to the config directory. ```YAML schema: schema.graphql documents: '**/*.graphql' ``` -------------------------------- ### Structure GraphQL Configurations for Multiple Projects Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This snippet illustrates how to manage multiple independent GraphQL schemas in a monorepo setup. By placing a `.graphql.config.yml` file in each product's subdirectory, separate schema scopes are created for each subtree. ```text - project root/ - product a (schema one)/ - .graphql.config.yml <----- - schema files and graphql aware components - product b (schema two)/ - .graphql.config.yml <----- - schema files and graphql aware components ``` -------------------------------- ### Advanced GraphQL Schema File Inclusion and Exclusion Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This example shows how to use `include` and `exclude` keys for fine-grained control over which files are part of the schema. It demonstrates including `schema.graphql` and files within `src` while excluding `__tests__` directories. ```yaml schema: schema.graphql exclude: 'src/**/__tests__/**' include: src/** ``` -------------------------------- ### TypeScript Configuration for ESM Modules with ts-node Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md Illustrates a `tsconfig.json` snippet necessary for loading TypeScript configuration files that use ESM modules. It configures `compilerOptions` for `ESNext` modules and sets `ts-node` to enable ESM support, requiring the `ts-node` package to be installed. ```json { "compilerOptions": { "module": "ESNext" }, "ts-node": { "esm": true } } ``` -------------------------------- ### Legacy GraphQL Config with Schema Path and Includes Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This JSON5 configuration illustrates a legacy GraphQL setup, specifying a single schema file via `schemaPath` and explicitly listing additional GraphQL files and patterns to include for schema construction using the `includes` property. It also shows how to exclude specific paths. ```json5 { // a default way to provide a single-source schema "schemaPath": "schema.graphql", "includes": [ "Types1.graphql", "types/**/*.graphql", "src/files/*.{graphql,js,ts}", "everything/inside/**" ], "excludes": [ "types/excluded/**" ] } ``` -------------------------------- ### GraphQL Config for Single File Multi-schema Projects Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/docs/developer-guide.md Demonstrates how to use the `projects` field with `includes` globs in a single `.graphqlconfig` file to define separate schema scopes for different products when using a monorepo setup. ```JSON { "projects": { "product a": { "includes": ["product a (schema one)/**"] }, "product b": { "includes": ["product b (schema two)/**"] } } } ``` -------------------------------- ### Gatsby GraphQL Config Setup Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This JavaScript snippet shows how to configure the GraphQL plugin for a Gatsby project by pointing the `graphql.config.js` file to the generated `graphql.config.json` within Gatsby's `.cache/typegen` directory. This ensures the plugin uses Gatsby's type generation for schema construction. ```javascript module.exports = require("./.cache/typegen/graphql.config.json") ``` -------------------------------- ### Comprehensive GraphQL Schema Definition Example Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/SchemaDescriptions.txt A complete GraphQL schema definition showcasing the declaration of a root `schema` with a `query` type, a `Query` object type with an `id` field, an `Input` object type, and an `Interface` type, each containing an `id` field. This snippet illustrates the basic building blocks of a GraphQL schema. ```GraphQL """ schema """ schema { query: Query } """ type """ type Query { id: ID } """ input """ input Input { id: ID } """ interface """ interface Interface { id: ID } ``` -------------------------------- ### Injecting GraphQL with IntelliJ Comment-Based Injection Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This example illustrates IntelliJ's comment-based injection, where `// language=GraphQL` is used to explicitly inform the IDE that the subsequent string literal contains GraphQL code. This enables full language support, including syntax highlighting, validation, and autocompletion. ```js // language=GraphQL const QUERY = `query { field }`; ``` -------------------------------- ### Define a GraphQL Object Type with Fields Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/SchemaDescriptions.txt Presents the definition of a GraphQL object type, 'TypeForUnion', with two fields: 'id' of type 'ID' and 'phone'. The type for 'phone' was not explicitly specified in the source and is inferred as 'String' to ensure a valid schema example. ```APIDOC """\n""" type TypeForUnion { """\n field\n """ id: ID """\n """ phone: String } ``` -------------------------------- ### Injecting GraphQL with Internal GraphQL Comments Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This example demonstrates embedding a `#graphql` comment directly within a multi-line string to indicate that the string contains GraphQL code. This approach is useful for scenarios where the GraphQL content is part of a larger string or file, allowing the plugin to correctly parse and validate it. ```js const QUERY = ` #graphql query { field } `; ``` -------------------------------- ### GraphQL Mutation Definition with Input Variable Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/ParsingTestData.txt Defines a GraphQL mutation named `MyMutation` that accepts a non-null input variable `$input` of type `MyInput`. This example shows the basic structure of a mutation operation, including variable definitions and an empty selection set. ```GraphQL mutation MyMutation($input: MyInput!) { # Payload } ``` -------------------------------- ### Example GraphQL Query with Arguments, Directives, and Nested Selection Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/ParsingTestData.txt This snippet reconstructs a GraphQL query from its PSI tree representation. It demonstrates a field with multiple arguments (a string and an object), a directive applied to the field with its own arguments, and a nested selection set, including an empty one which highlights parsing behavior. ```GraphQL field(arg: "test", foo: {more: true}) @onArg(test: {more: true}) { foo { } } ``` -------------------------------- ### GraphQL Object Type Definition Example Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/KeywordsAsIdentifiers.txt This snippet reconstructs the GraphQL schema definition from the provided AST (Abstract Syntax Tree) representation. It defines a simple GraphQL object type 'Foo' with two fields: 'type' and 'repeatable', both of type 'Boolean'. This demonstrates a basic object type structure in GraphQL. ```GraphQL type Foo { type: Boolean repeatable: Boolean } ``` -------------------------------- ### GraphQL Schema and Query Definition Example Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/ParsingTestData.txt This comprehensive GraphQL snippet demonstrates the definition of an object type `AnnotatedObject` with type-level and field-level directives. It includes a field `annotatedField` with a default-valued argument and an argument-level directive. Additionally, a basic `query` operation named `Foo` is defined. ```GraphQL ### --------- annotations.graphql --------- ### type AnnotatedObject @foo(foo: { test: true }) { annotatedField(arg: Type = "default" @onArg): Type @onField foo: String } query Foo { # ... selection set content is truncated in the input } ``` -------------------------------- ### Define GraphQL Fragment in JavaScript Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/schema/types/schemaInHtmlWithSOE/src/index.html This snippet illustrates how to embed a GraphQL fragment named 'UserFragment' within a JavaScript function. The fragment selects the 'name' field from a 'User' type, utilizing a 'gql' tagged template literal for GraphQL syntax highlighting and parsing. ```JavaScript function fn() { gql` fragment UserFragment on User { name } ` } ``` -------------------------------- ### Define GraphQL Query with Fragment in JavaScript Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/resolve/operations/FragmentInjectedResolvedToOtherInjection/index.html This snippet shows how to define a GraphQL query using a template literal tagged with `gql` in JavaScript. It fetches user data and includes a `UserFragment` for reusable data selection. This pattern is common in GraphQL client libraries like Apollo Client or Relay, where `gql` is typically imported from the library. ```JavaScript gql` query { user { ...UserFragment } } ` ``` -------------------------------- ### Extend GraphQL Schema with Directive and Operation Type Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/ExtendSchema.txt This snippet demonstrates how to extend an existing GraphQL schema using the `extend schema` keyword. It includes applying a custom directive (`@SchemaDirOneMore`) to the schema and defining a new operation type (`mutation`) with a specific type (`MyMutation`). This is useful for adding custom capabilities or modifying the root operation types of a schema without altering its original definition. ```GraphQL extend schema @SchemaDirOneMore { mutation: MyMutation } ``` -------------------------------- ### Define GraphQL Query with Fragment Spread in JavaScript Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/resolve/operations/FragmentInjectedInHtml/index.html This code snippet illustrates how to define a GraphQL query string using a JavaScript template literal tagged with `gql`. The query targets a `user` field and incorporates a fragment spread `...UserFragment`, which is a common pattern for reusing predefined sets of fields across multiple queries. This approach enhances query readability and maintainability in applications interacting with GraphQL APIs. ```JavaScript gql` query { user { ...UserFragment } } ` ``` -------------------------------- ### Basic Multi-Project GraphQL Configuration in YAML Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md Demonstrates a `.graphql.config.yml` file defining two distinct GraphQL projects, 'frontend' and 'backend'. Each project specifies its schema source (URL or local file) and document patterns. Files are matched against projects in the order they are defined. ```yaml projects: frontend: schema: https://my.api.com/graphql documents: frontend/**/*.{graphql,js,ts} backend: schema: backend/schema.graphql documents: backend/**/*.graphql ``` -------------------------------- ### GraphQL Plugin Toolbar Actions Reference Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md The GraphQL plugin provides a dedicated toolbar with quick access to commonly used actions. This section details each action available on the toolbar, including their purpose and functionality. ```APIDOC Toolbar Actions: Open Configuration File: description: Open the corresponding configuration file, or create a new one if it does not exist. Edit Environment Variables: description: Opens a dialog that allows you to provide values for environment variables that are defined in the associated configuration file. Toggle Variables Editor: description: Opens an editor window where you can provide query variables in JSON format. Endpoints list: description: A list of known URLs is defined in a config file, which you can use to select a URL where the GraphQL queries should go or from where the introspection should be fetched. Execute GraphQL: description: Run a selected GraphQL query from the editor below. Run Introspection Query: description: This action refreshes an introspected schema from the selected endpoint. Open Introspection Schema: description: This command opens a local file that corresponding to a selected endpoint. ``` -------------------------------- ### GraphQL Config Environment Variable Syntax Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This snippet demonstrates the syntax for utilizing environment variables within GraphQL configuration files. It shows how to reference a variable, provide a default fallback value, and use quoted values for URLs or other string-based settings. ```text ${VARIABLE_NAME} ${VARIABLE_WITH_DEFAULT:./some/default/file.graphql} ${VARIABLE_QUOTED:"http://localhost:4000/graphql"} ``` -------------------------------- ### Multi-schema Project Structure with Multiple GraphQL Config Files Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/docs/developer-guide.md This recommended approach places separate `.graphqlconfig` files within each product's schema folder, creating distinct scopes for different GraphQL schemas. ```Text - project root/ - product a (schema one)/ - .graphqlconfig <----- - schema files and graphql aware components - product b (schema two)/ - .graphqlconfig <----- - schema files and graphql aware components ``` -------------------------------- ### GraphQL Config Schema with Environment Variable Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This YAML configuration shows how to dynamically set the `schema` path using an environment variable, providing a fallback default value if the variable is not defined. This allows for flexible schema location based on the deployment environment. ```yaml schema: ${SCHEMA_FILE:./schema.json} ``` -------------------------------- ### Configuring GraphQL Scratch Files Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md GraphQL scratch files can be configured to use a specific GraphQL configuration and project for resolution and type validation. This is achieved by including a leading comment in the format `# config=[!]`. ```YAML # config=/user/local/project/.graphqlrc.yml # config=/user/local/project/.graphqlrc.yml!backend ``` -------------------------------- ### Configuring Composite GraphQL Schema with File List Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This configuration shows how to assemble a single GraphQL schema object from multiple modularized schema files. By listing individual `.graphql` files, GraphQL Config reads and merges them, allowing for a distributed schema definition. ```YAML schema: - ./foo.graphql - ./bar.graphql - ./baz.graphql ``` -------------------------------- ### Define a GraphQL Directive Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/SchemaDescriptions.txt Shows how to define a GraphQL directive, '@Directive', which can be applied 'on SCHEMA'. Includes a description for the directive. ```APIDOC """\ndirective\n""" directive @Directive on SCHEMA ``` -------------------------------- ### Injecting GraphQL with C-Style Comments Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This snippet shows an alternative method for GraphQL injection using a C-style comment `/* GraphQL */` immediately preceding a string literal. Similar to the line comment, this tells the IDE to treat the string content as GraphQL, providing enhanced development features. ```js const QUERY = /* GraphQL */ `query { field }`; ``` -------------------------------- ### Multi-schema Project Structure with a Single GraphQL Config File Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/docs/developer-guide.md An alternative approach uses a single `.graphqlconfig` file at the project root. This requires explicit separation of schemas using the `projects` field within the configuration. ```Text - project root/ - .graphqlconfig <----- - product a (schema one)/ - schema files and graphql aware components - product b (schema two)/ - schema files and graphql aware components ``` -------------------------------- ### Multi-Project GraphQL Configuration with Exclude Pattern Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md Extends the multi-project YAML configuration by adding an `exclude` pattern to the 'frontend' project. This ensures that GraphQL documents in the 'queries' folder are not associated with 'frontend', enabling them to be matched by subsequent projects like 'backend' or a default project. ```yaml projects: frontend: schema: https://my.api.com/graphql documents: frontend/**/*.{graphql,js,ts} exclude: queries/** # <--- will enable strict matching for that project backend: schema: backend/schema.graphql documents: backend/**/*.graphql ``` -------------------------------- ### Configure Remote GraphQL Schemas with Introspection Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This section demonstrates how to define remote GraphQL endpoints for introspection. It shows various YAML configurations for single or multiple endpoints, including how to specify HTTP headers for authentication using environment variables. ```yaml schema: https://my.api.com/graphql schema: - https://my.api.com/one/graphql - https://my.api.com/two/graphql schema: - https://my.api.com/one/graphql: headers: Authorization: Bearer ${TOKEN} ``` -------------------------------- ### Configuring Composite GraphQL Schema with Glob Patterns Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This configuration illustrates using glob patterns to include multiple schema files for a composite GraphQL schema. It allows for recursively including all GraphQL files (`**/*.graphql`) or files in the current directory (`./*.graphql`), which are then merged into a single schema object. ```YAML schema: ./*.graphql # includes every GraphQL file in current directory # OR schema: ./**/*.graphql # includes GraphQL files recursively ``` -------------------------------- ### GraphQL Config Schema Endpoint with Quoted Environment Variable Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This YAML configuration demonstrates how to define a fallback endpoint for the schema using an environment variable, ensuring the value is properly quoted. This is useful for specifying URLs or other string values that might contain special characters. ```yaml schema: ${SCHEMA_ENDPOINT:"http://localhost:4000/graphql"} ``` -------------------------------- ### Injecting GraphQL with Tagged Template Literals Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This snippet demonstrates how to use tagged template literals, such as `gql`, to embed GraphQL queries or mutations directly within JavaScript code. This method is commonly supported by GraphQL client libraries and IDEs for syntax highlighting and validation. ```js const QUERY = gql``; ``` -------------------------------- ### Define a GraphQL Enum Type Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/SchemaDescriptions.txt Demonstrates how to define a GraphQL enumeration type, 'Enum', with a single value 'A'. Includes a multi-line description for the enum. ```APIDOC """\nenum\n""" enum Enum { A } ``` -------------------------------- ### Configuring GraphQL Endpoints in .graphqlconfig Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/docs/developer-guide.md Describes the structure for defining GraphQL endpoints within a `.graphqlconfig` file, including the URL, headers, and the `introspect` flag for automatic schema updates. This allows the plugin to run queries and mutations against remote schemas. ```APIDOC GraphQLConfig.endpoints: type: object description: A map of named GraphQL endpoints for running queries and introspection. properties: [endpoint_name]: type: object | string description: Configuration for a specific GraphQL endpoint. Can be a string (URL) or an object. properties: url: type: string description: The URL of the GraphQL endpoint. required: true headers: type: object description: A map of HTTP headers to send with requests to the endpoint. properties: [header_name]: type: string description: The value for the specified HTTP header. introspect: type: boolean description: If true, the plugin will prompt to update the local schema using this endpoint at project startup. default: false Note: The 'schemaPath' property, where the introspected schema is saved, is typically configured at the project level, not directly within the endpoint definition itself, but is crucial for the introspection workflow. ``` -------------------------------- ### Define a GraphQL Query Type with Comments and Descriptions Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/Emoji.txt This snippet illustrates how to define a basic GraphQL 'Query' object type. It includes an end-of-line comment, a multi-line block string description for the type, and an inline quoted string description for a field. The 'Query' type contains a single field, 'id', of type 'ID'. ```GraphQL # comment 🚨 emoji """ Description 🚨 emoji """ type Query { "Inline description 🚨 emoji" id: ID } ``` -------------------------------- ### Store Local Introspection Results for GraphQL Schemas Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/README.md This configuration allows storing introspection results locally by defining endpoints within the `extensions.endpoints` section. The schema will be saved to the specified local file path, such as `local.graphql`. ```yaml schema: local.graphql extensions: endpoints: One: url: https://my.api.com/one/graphql headers: Authorization: bearer ${TOKEN} Two: url: https://my.api.com/two/graphql ``` -------------------------------- ### Define GraphQL Scalar Type A with Empty Description Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/MultilineDescriptions.txt This snippet defines a basic GraphQL scalar type named 'A'. It includes an empty block string as its description, illustrating the minimal syntax for scalar type definitions. ```GraphQL scalar A ``` -------------------------------- ### Define a GraphQL Scalar Type Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/SchemaDescriptions.txt Illustrates the definition of a custom GraphQL scalar type, 'Scalar', with a descriptive comment. ```APIDOC """\nscalar\n""" scalar Scalar ``` -------------------------------- ### Define Multiple GraphQL Fragments in JavaScript Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/schema/types/fragmentsInInjections/src/index.html This snippet shows a JavaScript function containing two distinct GraphQL fragment definitions. Each fragment specifies a different set of fields for the 'User' type, demonstrating how to encapsulate reusable GraphQL queries. ```JavaScript function fn() { gql` fragment FragmentThree on User { name children { ...FragmentOne } } ` gql` fragment FragmentFour on User { name } ` } ``` -------------------------------- ### Define a Repeatable GraphQL Directive Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/Directives.txt This snippet defines a GraphQL directive named `RepeatableDirective` that can be applied multiple times to the same location. It is specified to be applicable only to `OBJECT` types in the schema. ```GraphQL directive @RepeatableDirective repeatable on OBJECT ``` -------------------------------- ### GraphQL Query with Arguments and Directives Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/ParsingTestData.txt This snippet showcases a GraphQL query with two top-level fields: `hero` and `test`. The `hero` field demonstrates various argument types including an array of floats, a boolean, an integer, and variable references. The `test` field includes an `@include` directive with a boolean `if` argument and selects a nested `union` field to retrieve its `__typename`. ```GraphQL { hero( array: [1.23, 1.3e-1, -1.35384e+3] boolean: true id: 123 object: $foo enum: $site ) test @include(if: true) { union { __typename } } } ``` -------------------------------- ### GraphQL Fragment for Directive Location Definition Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/ParsingTestData.txt This GraphQL fragment, `DirectiveLocation`, is designed to query metadata about directives within a GraphQL schema. It includes fields to retrieve the directive's `description`, its `args` (which references the `InputValue` fragment for detailed argument information), and boolean flags like `onField` and `onFragment` to indicate where the directive can be applied. ```GraphQL fragment DirectiveLocation on __Directive { description args { ...InputValue } onField onFragment onField } ``` -------------------------------- ### GraphQL Schema Introspection Query Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/ParsingTestData.txt This GraphQL query performs introspection on the connected GraphQL server to retrieve metadata about its schema. It fetches the names of the query, mutation, and subscription root types, a list of all defined types (using a fragment spread for 'FullType', which is not included in this snippet), and the names of all directives. ```GraphQL ### --------- introspection.graphql --------- #### query IntrospectionQuery { __schema { queryType { name } mutationType { name } subscriptionType { name } types { ...FullType } directives { name ``` -------------------------------- ### Define GraphQL Scalar with Comprehensive Escaped Description Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/SingleLineDescriptions.txt Shows a GraphQL scalar definition with a description containing various escape sequences, including backslashes (\\), single quotes (\'), backspace (\b), form feed (\f), newline (\n), carriage return (\r), tab (\t), double quotes (\"), forward slash (\/), unicode (\u1234), and literal backslash followed by 'u' (\\u12). ```GraphQL "\\ \\' \b \f \n \r \t \" \/ \u1234 \\u12" scalar C ``` -------------------------------- ### Reconstructed GraphQL Query with Fragment and Aliases Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/ParsingTestData.txt A GraphQL query reconstructed from a parse tree, demonstrating the use of a fragment spread, aliased fields ('first', 'second'), and arguments with different literal types (integer '1234', string '"foo"', boolean 'true'). It also includes a fragment definition, though its complete type condition and selection set were not fully provided in the original parse tree. ```GraphQL query { ...FullType first: node(id: 1234) { id } second: node(id: "foo", option: true) { id } } fragment FullType on Type { # Selection set for FullType fragment is not provided in the snippet. } ``` -------------------------------- ### Define a GraphQL Scalar Type with a Block String Description Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/MultilineDescriptions.txt This snippet defines a GraphQL scalar type named 'H' and includes a multi-line block string description. The description demonstrates how special characters, such as single quotes and triple quotes, can be included within the documentation block. ```GraphQL """ '""" """ scalar H ``` -------------------------------- ### Define a GraphQL Object Type with a Field and Block String Description Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/MultilineDescriptions.txt This snippet defines a GraphQL object type named 'G' which contains a single field 'f' of type 'String'. The field 'f' includes a multi-line block string description, demonstrating how complex string content, including escaped quotes, can be embedded as documentation within the schema. ```GraphQL type G { """ """" """ f: String } ``` -------------------------------- ### IntelliJ PSI Structure for GraphQL Type Fields Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/ParsingTestData.txt This snippet displays the raw PSI tree generated by the JetBrains GraphQL IntelliJ plugin when parsing a GraphQL query that selects various fields related to a type's definition. It highlights the hierarchical structure of GraphQL elements like fields, selection sets, identifiers, and fragment spreads, as interpreted by the IDE's internal parser. ```GraphQL GraphQLIdentifierImpl(IDENTIFIER)(561,565) PsiElement(NAME)('args')(561,565) PsiWhiteSpace(' ')(565,566) GraphQLSelectionSetImpl(SELECTION_SET)(566,603) PsiElement({)('{')(566,567) PsiWhiteSpace('\n ')(567,580) GraphQLSelectionImpl(SELECTION)(580,593) GraphQLFragmentSelectionImpl(FRAGMENT_SELECTION)(580,593) PsiElement(...)('...')(580,583) GraphQLFragmentSpreadImpl(FRAGMENT_SPREAD)(583,593) GraphQLIdentifierImpl(IDENTIFIER)(583,593) PsiElement(NAME)('InputValue')(583,593) PsiWhiteSpace('\n ')(593,602) PsiElement(})('}')(602,603) PsiWhiteSpace('\n ')(603,612) GraphQLSelectionImpl(SELECTION)(612,651) GraphQLFieldImpl(FIELD)(612,651) GraphQLIdentifierImpl(IDENTIFIER)(612,616) PsiElement(type)('type')(612,616) PsiWhiteSpace(' ')(616,617) GraphQLSelectionSetImpl(SELECTION_SET)(617,651) PsiElement({)('{')(617,618) PsiWhiteSpace('\n ')(618,631) GraphQLSelectionImpl(SELECTION)(631,641) GraphQLFragmentSelectionImpl(FRAGMENT_SELECTION)(631,641) PsiElement(...)('...')(631,634) GraphQLFragmentSpreadImpl(FRAGMENT_SPREAD)(634,641) GraphQLIdentifierImpl(IDENTIFIER)(634,641) PsiElement(NAME)('TypeRef')(634,641) PsiWhiteSpace('\n ')(641,650) PsiElement(})('}')(650,651) PsiWhiteSpace('\n ')(651,660) GraphQLSelectionImpl(SELECTION)(660,672) GraphQLFieldImpl(FIELD)(660,672) GraphQLIdentifierImpl(IDENTIFIER)(660,672) PsiElement(NAME)('isDeprecated')(660,672) PsiWhiteSpace('\n ')(672,681) GraphQLSelectionImpl(SELECTION)(681,698) GraphQLFieldImpl(FIELD)(681,698) GraphQLIdentifierImpl(IDENTIFIER)(681,698) PsiElement(NAME)('deprecationReason')(681,698) PsiWhiteSpace('\n ')(698,703) PsiElement(})('}')(703,704) PsiWhiteSpace('\n ')(704,709) GraphQLSelectionImpl(SELECTION)(709,750) GraphQLFieldImpl(FIELD)(709,750) GraphQLIdentifierImpl(IDENTIFIER)(709,720) PsiElement(NAME)('inputFields')(709,720) PsiWhiteSpace(' ')(720,721) GraphQLSelectionSetImpl(SELECTION_SET)(721,750) PsiElement({)('{')(721,722) PsiWhiteSpace('\n ')(722,731) GraphQLSelectionImpl(SELECTION)(731,744) GraphQLFragmentSelectionImpl(FRAGMENT_SELECTION)(731,744) PsiElement(...)('...')(731,734) GraphQLFragmentSpreadImpl(FRAGMENT_SPREAD)(734,744) GraphQLIdentifierImpl(IDENTIFIER)(734,744) PsiElement(NAME)('InputValue')(734,744) PsiWhiteSpace('\n ')(744,749) PsiElement(})('}')(749,750) PsiWhiteSpace('\n ')(750,755) GraphQLSelectionImpl(SELECTION)(755,792) GraphQLFieldImpl(FIELD)(755,792) GraphQLIdentifierImpl(IDENTIFIER)(755,765) PsiElement(NAME)('interfaces')(755,765) PsiWhiteSpace(' ')(765,766) GraphQLSelectionSetImpl(SELECTION_SET)(766,792) PsiElement({)('{')(766,767) PsiWhiteSpace('\n ')(767,776) GraphQLSelectionImpl(SELECTION)(776,786) GraphQLFragmentSelectionImpl(FRAGMENT_SELECTION)(776,786) PsiElement(...)('...')(776,779) GraphQLFragmentSpreadImpl(FRAGMENT_SPREAD)(779,786) GraphQLIdentifierImpl(IDENTIFIER)(779,786) PsiElement(NAME)('TypeRef')(779,786) PsiWhiteSpace('\n ')(786,791) PsiElement(})('}')(791,792) PsiWhiteSpace('\n ')(792,797) GraphQLSelectionImpl(SELECTION)(797,895) GraphQLFieldImpl(FIELD)(797,895) GraphQLIdentifierImpl(IDENTIFIER)(797,807) PsiElement(NAME)('enumValues')(797,807) PsiWhiteSpace(' ')(807,808) GraphQLSelectionSetImpl(SELECTION_SET)(808,895) PsiElement({)('{')(808,809) PsiWhiteSpace('\n ')(809,818) GraphQLSelectionImpl(SELECTION)(818,822) GraphQLFieldImpl(FIELD)(818,822) GraphQLIdentifierImpl(IDENTIFIER)(818,822) PsiElement(NAME)('name')(818,822) PsiWhiteSpace('\n ')(822,831) GraphQLSelectionImpl(SELECTION)(831,842) GraphQLFieldImpl(FIELD)(831,842) GraphQLIdentifierImpl(IDENTIFIER)(831,842) ``` -------------------------------- ### Define GraphQL Scalar Type F with Mixed Quotes and Newlines in Description Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/MultilineDescriptions.txt This snippet defines a GraphQL scalar type named 'F'. Its description block string illustrates a combination of single and double quotes, as well as newlines and triple quotes, demonstrating complex formatting within GraphQL block string descriptions. ```GraphQL scalar F ``` -------------------------------- ### Define GraphQL Scalar with Empty Description Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/SingleLineDescriptions.txt Demonstrates a basic GraphQL scalar type definition with an empty string as its description. ```GraphQL "" scalar A ``` -------------------------------- ### GraphQL Query Definition with Multiple Variables Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/ParsingTestData.txt Illustrates a GraphQL query named `queryName` that defines two input variables: `$foo` of type `TestInput` and `$site` of type `TestEnum`. This snippet focuses on the syntax for declaring multiple variables in a query operation. ```GraphQL query queryName($foo: TestInput, $site: TestEnum) ``` -------------------------------- ### Define a Basic GraphQL Type using gql Tag Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/schema/builder/schemaInInjections/type2/type2.html This snippet shows how to define a simple GraphQL object type named `Type2` with a single field `type2` of type `String`. The definition is enclosed within a JavaScript template literal tagged with `gql`, a common pattern for parsing GraphQL schemas or queries in JavaScript environments. ```JavaScript gql` type Type2 { type2: String } ` ``` -------------------------------- ### GraphQL Introspection Query for Type Fields Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/ParsingTestData.txt Demonstrates a basic GraphQL introspection query to retrieve fields of the `__Type` type, specifically showing the 'name' field. This snippet illustrates how to query metadata about the GraphQL schema itself. ```GraphQL __Type { # Note: __Type has a lot more fields than this name } ``` -------------------------------- ### Define a Non-Repeatable GraphQL Directive Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/Directives.txt This snippet defines a GraphQL directive named `NonRepeatableDirective` which can only be applied once to a given location. It is specified to be applicable only to `OBJECT` types in the schema. ```GraphQL directive @NonRepeatableDirective on OBJECT ``` -------------------------------- ### Define GraphQL Scalar Type B with Newline Description Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/MultilineDescriptions.txt This snippet defines a GraphQL scalar type named 'B'. Its description block string contains a single newline character, demonstrating how whitespace, including newlines, is preserved within block string descriptions. ```GraphQL scalar B ``` -------------------------------- ### Define GraphQL Scalar with Escaped Single Quote in Description Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/SingleLineDescriptions.txt Shows a GraphQL scalar definition with a description that includes an escaped single quote (\'), demonstrating how such characters are represented. ```GraphQL "\'" scalar G ``` -------------------------------- ### Define GraphQL Fragment for __InputValue Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/ParsingTestData.txt This GraphQL fragment, named `InputValue`, is designed to query details about `__InputValue` types in a GraphQL schema. It includes selections for the input value's `name`, `description`, its `type` (which itself references the `TypeRef` fragment for nested type details), and `defaultValue`. ```GraphQL fragment InputValue on __InputValue { name description type { ...TypeRef } defaultValue } ``` -------------------------------- ### Define GraphQL Scalar Type C with Multiple Newlines Description Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/MultilineDescriptions.txt This snippet defines a GraphQL scalar type named 'C'. The description block string contains two newline characters, further illustrating the preservation of multiple newlines within GraphQL block string descriptions. ```GraphQL scalar C ``` -------------------------------- ### Define a Basic GraphQL Scalar Type Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/MultilineDescriptions.txt This snippet defines a simple GraphQL scalar type named 'F'. Scalar types represent primitive data, such as strings, numbers, or booleans, and can also be custom types like `Date` or `JSON`. ```GraphQL scalar F ``` -------------------------------- ### Define GraphQL Scalar Type D with Escaped Triple Quotes in Description Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/MultilineDescriptions.txt This snippet defines a GraphQL scalar type named 'D'. Its description block string demonstrates how to include literal triple quotes ("""") within the description content by escaping them, showcasing advanced block string usage. ```GraphQL scalar D ``` -------------------------------- ### Define GraphQL Scalar with Incomplete Unicode Escape (\u) in Description Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/SingleLineDescriptions.txt Illustrates a GraphQL scalar definition with a description containing a very incomplete unicode escape sequence (\u), which is likely treated as a literal string. ```GraphQL "\u" scalar F ``` -------------------------------- ### Define GraphQL Scalar with Incomplete Unicode Escape (\u12) in Description Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/SingleLineDescriptions.txt Demonstrates a GraphQL scalar definition where the description contains an incomplete unicode escape sequence (\u12), which might be treated as a literal string depending on the parser. ```GraphQL "\u12" scalar E ``` -------------------------------- ### GraphQL Field with Alias and String Argument Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/ParsingTestData.txt This snippet shows a GraphQL field named 'hasArgs' with an alias 'testAlias', taking a 'string' argument with the value 'testString'. This is a common pattern for renaming fields in the response and passing scalar values within a GraphQL query. ```GraphQL testAlias: hasArgs(string: "testString") ``` -------------------------------- ### Define GraphQL Scalar with Escaped Double Quote in Description Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/SingleLineDescriptions.txt Illustrates how to include an escaped double quote character (\" ) within a GraphQL scalar's description string. ```GraphQL "\"" scalar B ``` -------------------------------- ### Define GraphQL Scalar Type E with Various Escaped Characters in Description Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/MultilineDescriptions.txt This snippet defines a GraphQL scalar type named 'E'. Its description block string contains a variety of escaped characters, including backticks, single quotes, double quotes, and triple quotes, demonstrating comprehensive escaping within GraphQL block strings. ```GraphQL scalar E ``` -------------------------------- ### Define GraphQL Scalar with Invalid Escape Sequence (\T) in Description Source: https://github.com/jetbrains/js-graphql-intellij-plugin/blob/master/tests/testData/graphql/parser/SingleLineDescriptions.txt Presents a GraphQL scalar definition where the description contains an invalid escape sequence (\T), highlighting how parsers might handle non-standard escapes. ```GraphQL "\T" scalar H ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.