{"id":48878,"library":"parrot-graphql","title":"Parrot-GraphQL","description":"Parrot-GraphQL is a helper library for creating GraphQL mocks used with Parrot, resolving both GET and POST requests to GraphQL endpoints. Version 5.3.0 wraps @graphql-tools/mock's mockServer to define mocking logic per schema type. It simplifies mocking GraphQL queries by allowing users to provide a schema string and custom mock resolvers, integrated seamlessly with Parrot's scenario-based testing. Released under American Express, it targets Node.js with CommonJS require syntax, though ESM may be available in newer versions. The library is ideal for integration and end-to-end testing with GraphQL APIs.","status":"active","version":"5.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/americanexpress/parrot","tags":["javascript"],"install":[{"cmd":"npm install parrot-graphql","lang":"bash","label":"npm"},{"cmd":"yarn add parrot-graphql","lang":"bash","label":"yarn"},{"cmd":"pnpm add parrot-graphql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core mocking engine used to create mock server from schema and mocks.","package":"@graphql-tools/mock","optional":false},{"reason":"Run-time peer dependency for creating scenarios; the graphql() function returns handlers consumable by Parrot.","package":"parrot","optional":false}],"imports":[{"note":"The library exports a named export 'graphql' (not default). CommonJS require with destructuring is correct.","wrong":"const graphql = require('parrot-graphql');","symbol":"graphql","correct":"const { graphql } = require('parrot-graphql');"},{"note":"ESM import must use named import syntax. Default import is not available.","wrong":"import graphql from 'parrot-graphql';","symbol":"graphql","correct":"import { graphql } from 'parrot-graphql';"},{"note":"Avoid subpath imports; the function is at the package root.","wrong":"const graphql = require('parrot-graphql/graphql');","symbol":"graphql","correct":"const graphql = require('parrot-graphql').graphql;"}],"quickstart":{"code":"const { graphql } = require('parrot-graphql');\nconst casual = require('casual');\n\nconst schema = `\n  type Query {\n    user(id: ID!): User\n  }\n  type User {\n    id: ID!\n    name: String!\n    email: String!\n  }\n`;\n\nconst scenarios = {\n  'returns a user': [\n    graphql('/graphql', schema, {\n      User: () => ({\n        id: '1',\n        name: casual.name,\n        email: casual.email,\n      }),\n    }),\n  ],\n};\n\nmodule.exports = scenarios;","lang":"javascript","description":"Creates a Parrot scenario that mocks a GraphQL endpoint with custom resolver logic using casual library."},"warnings":[{"fix":"Change 'const graphql = require(\"parrot-graphql\");' to 'const { graphql } = require(\"parrot-graphql\");'","message":"Version 5.x removed default export; use named import { graphql }.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Install parrot separately: npm install parrot --save-dev","message":"The peer dependency 'parrot' is required but not automatically installed.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure schema is a string, e.g., const schema = `type Query { hello: String }`;","message":"GraphQL schema must be provided as a string; SDL object not supported.","severity":"gotcha","affected_versions":"*"},{"fix":"Provide mock resolvers per type, not per field (e.g., mocks.User = () => ({...})).","message":"Mocks object keys must correspond to GraphQL type names (not field names).","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'/mock':33 '5.3.0':28 'allow':49 'american':71 'api':102 'avail':84 'base':67 'commonj':77 'creat':12 'custom':57 'defin':37 'end':96,98 'end-to-end':95 'endpoint':26 'esm':81 'express':72 'get':20 'graphql':3,6,13,25,31,46,101 'graphql-tool':30 'helper':9 'ideal':91 'integr':60,93 'javascript':103 'librari':10,89 'logic':39 'may':82 'mock':14,38,45,58 'mockserv':35 'newer':86 'node.js':75 'parrot':2,5,17,63 'parrot-graphql':1,4 'per':40 'post':22 'provid':52 'queri':47 'releas':69 'request':23 'requir':78 'resolv':18,59 'scenario':66 'scenario-bas':65 'schema':41,54 'seamless':61 'simplifi':44 'string':55 'syntax':79 'target':74 'test':68,99 'though':80 'tool':32 'type':42 'use':15 'user':50 'version':27,87 'wrap':29","created_at":"2026-06-07T16:58:55.766801+00:00","updated_at":"2026-06-07T16:58:55.766801+00:00","problems":[{"fix":"Run npm install parrot-graphql --save-dev","cause":"Package not installed or missing from node_modules.","error":"Cannot find module 'parrot-graphql'"},{"fix":"Use const { graphql } = require('parrot-graphql');","cause":"Using default import instead of named import.","error":"graphql is not a function"},{"fix":"Ensure the schema is a string literal or template string.","cause":"Schema argument is undefined or not a string.","error":"Must provide a valid GraphQL schema string"},{"fix":"Install @graphql-tools/mock: npm install @graphql-tools/mock --save-dev","cause":"Missing @graphql-tools/mock dependency or incompatible version.","error":"Cannot read property 'mockServer' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/americanexpress/parrot#readme","github":"https://github.com/americanexpress/parrot","docs":null,"changelog":null,"pypi":null,"npm":"parrot-graphql","openapi_spec":null,"status_page":null,"smithery":null,"categories":["testing"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}