Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Fix issues with duplicate fragments
Browse files Browse the repository at this point in the history
This also adds the first tests to make sure everything keeps working
  • Loading branch information
mvantellingen committed Sep 3, 2024
1 parent c7e9b9a commit 91c6964
Show file tree
Hide file tree
Showing 13 changed files with 354 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-peas-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@labdigital/graphql-codegen-bruno": minor
---

Fix issues with duplicate fragments
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/*
node_modules/*
coverage/*
src/__output__/*
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@labdigital/graphql-codegen-bruno",
"version": "1.0.4",
"type": "commonjs",
"main": "dist/index.js",
"publishConfig": {
"access": "public"
Expand All @@ -22,6 +23,8 @@
},
"devDependencies": {
"@changesets/cli": "^2.27.7",
"@graphql-tools/graphql-file-loader": "^8.0.1",
"@graphql-tools/load": "^8.0.2",
"@types/fs-extra": "^11.0.4",
"@types/node": "^22.5.2",
"@vitest/coverage-v8": "^2.0.5",
Expand All @@ -31,5 +34,10 @@
"peerDependencies": {
"graphql": "^16.9.0"
},
"pnpm": {
"overrides": {
"graphql": "16.9.0"
}
},
"packageManager": "pnpm@9.9.0"
}
112 changes: 108 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions src/__mocks__/query.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# query.graphql

query GetCustomer($info: CustomerInfo!) {
customer(info: $info) {
...CustomerDetails
}
}

fragment CustomerDetails on Customer {
firstName
email
addresses {
...AddressDetails
}
}

fragment AddressDetails on Address {
id
city
}
41 changes: 41 additions & 0 deletions src/__mocks__/schema.graphqls
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
type Query {
customer(info: CustomerInfo!): Customer
product(id: ID!): Product
}

input CustomerInfo {
credentials: Credentials!
authMethod: AuthMethod!
}

enum AuthMethod {
EMAIL
PHONE
}

input Credentials {
email: String!
password: String!
}

type Customer {
id: ID!
firstName: String!
email: String!
addresses: [Address!]!
}

type Product {
id: ID!
name: String!
price: Float!
}

type Address {
id: ID!
email: String
firstName: String
lastName: String
city: String
}

57 changes: 57 additions & 0 deletions src/__snapshots__/queries/GetCustomer.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

meta {
name: GetCustomer
type: graphql
}

post {
url: {{graphql-gateway}}/graphql
body: graphql
auth: none
}

body:graphql {
query GetCustomer($info: CustomerInfo!) {
customer(info: $info) {
...CustomerDetails
}
}

fragment CustomerDetails on Customer {
firstName
email
addresses {
...AddressDetails
}
}

fragment AddressDetails on Address {
id
city
}
fragment CustomerDetails on Customer {
firstName
email
addresses {
...AddressDetails
}
}
fragment AddressDetails on Address {
id
city
}

}

body:graphql:vars {
{
"info": {
"credentials": {
"email": "example",
"password": "example"
},
"authMethod": "EMAIL"
}
}
}

Loading

0 comments on commit 91c6964

Please sign in to comment.